#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,a,b,c;
    cin>>n>>a>>b>>c;
    int res=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++ ){
            int k=(n-(i*a)-(j*b))/c;
            if(k<0){k=0;}
            if((i*a)+(j*b)+(c*k)==n){
                res=max(res,i+j+k);
            }
        }
    }
    cout <<res;
    return 0;
}


#include <iostream>

using namespace std;

int main(){
    long long n, x, y;

    cin >> n >> x >> y;

    long long a1 = y - n + 1;

    if (a1 > 0 && a1 * a1 >= x - n + 1){
        cout << a1 << " ";
        for (int i = 1; i < n; i++){
            cout << 1 << " ";
        }
    }
    else cout << -1;

}


#include <iostream>

using namespace std;

int main()
{
    int w;

    cin>>w;
    if (w==1||w==2||w%2==1)
        cout<<"no";
    else
        cout<<"yes";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define endl '\n'

void solve()
{
    string a,b;
    cin>>a>>b;
    for (ll i=0;i<a.length();i++)
    {
        if (a[i]==b[i])
        {
            cout<<"0";
        }
        else
        {
            cout<<"1";
        }
    }

}

int main() {
    ll testcase = 1;
    //    cin >> testcase;                      // Comment out this line for single test case
    while (testcase--) {
        solve();
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9+7;
#define INF 0x3f3f3f3f3f3f3f
#define inf -INF

#define int ll
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl '\n'
const int N = 1e5+10;
int dxy[2][4]={{0,0,1,-1},{1,-1,0,0}};
bool cmp(pair<int,int>a,pair<int,int>b)
{
    return a.first<b.first;
}
map<string,bool>setup,information;
signed main() {
#ifdef GRBFL
    freopen("1.input", "r", stdin);
    freopen("1.output", "w", stdout);
#endif
    set<int>a;
    for(int i = 0;i<4;i++)
    {
        int x;
        cin>>x;
        a.insert(x);
    }
    cout<<4-a.size()<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i<n; i++)
#define repc(i, a, b) for(int i = a; i<b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define fast_io std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define sortv(v) sort(v.begin(), v.end())
#define reversev(v) sort(v.begin(), v.end())
#define all(v) (v.begin(), v.end())

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef vector<bool> vb;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mi;
typedef pair<int, int> pi;
typedef map<ll, ll> mll;
typedef pair<ll, ll> pll;
bool func(int mid,int k,int n){
    int total = mid;
    while(mid/k!=0){
        mid = mid/k;
        total += mid;
    }
    if(total>=n) return true;
    return false;
}
int main() {
    fast_io;
    int n,k;
    cin>>n>>k;
    int lo =0;
    int hi = n;
    int mid;
    int ans ;
    while(lo<=hi){
        mid = (lo+hi)>>1;
        if(func(mid,k,n)){
            ans = mid;
            hi = mid-1;
        }
        else{
            lo= mid+1;
        }
    }
    cout<<ans<<endl;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
using namespace std;

int main(void)
{
    int n;
    double b;
    cin >> n >> b;
    vector<double> v(n);
    vector<double> r(n);
    double res = 0, m = 0;
    for (int i = 0; i != n; ++i)
    {
        cin >> v[i];
        res += v[i];
        m = max(m, v[i]);
    }

    if (m * n - res > b)
    {
        cout << -1;
        return 0;
    }
    else
        res += b;

    res /= n;

    for (int i = 0; i != n; ++i)
        printf("%.6f\n", res - v[i]);

    return 0;
}


#include<cstdio>
int ans[111][111]={};
int main()
{
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	if(n>a*b){printf("-1\n");return 0;}
	int cnt=1;
	for(int i=0;i<a;i++)
	{
		for(int j=1&i;j<b;j=j+2)
			ans[i][j]=cnt,cnt+=2;
	}
	cnt=2;
	for(int i=0;i<a;i++)
		for(int j=!(1&i);j<b;j=j+2)
			ans[i][j]=cnt,cnt+=2;
	for(int i=0;i<a;i++)
	{
		for(int j=0;j<b;j++)
			if(ans[i][j]>n)
				printf("0 ");
			else printf("%d ",ans[i][j]);
		printf("\n");
	}
}


/*
    Rezwan_4029 , AUST
*/
#include <bits/stdc++.h>

#define pb push_back
#define all(x) x.begin(),x.end()
#define ms(a,v) memset(a,v,sizeof a)
#define II ({int a; scanf("%d", &a); a;})
#define LL ({Long a; scanf("%lld", &a); a;})
#define DD ({double a; scanf("%lf", &a); a;})
#define ff first
#define ss second
#define mp make_pair
#define gc getchar
#define EPS 1e-10
#define pi 3.1415926535897932384626433832795
using namespace std;

#define FI freopen ("in.txt", "r", stdin)
#define FO freopen ("out.txt", "w", stdout)

typedef long long Long;
typedef unsigned long long ull;
typedef vector<int> vi ;
typedef set<int> si;
typedef vector<Long>vl;
typedef pair<int,int>pii;
typedef pair<string,int>psi;
typedef pair<Long,Long>pll;
typedef pair<double,double>pdd;
typedef vector<pii> vpii;

#define forab(i, a, b)	for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n)		forab (i, 0, (n) - 1)
#define For(i, n)		forab (i, 1, n)
#define rofba(i, a, b)	for (__typeof (b)i = (b) ; i >= a ; --i)
#define per(i, n)		rofba (i, 0, (n) - 1)
#define rof(i, n)		rofba (i, 1, n)
#define forstl(i, s)	for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)

#define __(args...) {dbg,args; cerr<<endl;}
struct debugger{template<typename T> debugger& operator , (const T& v){cerr<<v<<"\t"; return *this; }}dbg;
#define __1D(a,n) rep(i,n) { if(i) printf(" ") ; cout << a[i] ; }
#define __2D(a,r,c,f) forab(i,f,r-!f){forab(j,f,c-!f){if(j!=f)printf(" ");cout<<a[i][j];}cout<<endl;}

template<class A, class B> ostream &operator<<(ostream& o, const pair<A,B>& p){ return o<<"("<<p.ff<<", "<<p.ss<<")";} //Pair print
template<class T> ostream& operator<<(ostream& o, const vector<T>& v){ o<<"[";forstl(it,v)o<<*it<<", ";return o<<"]";} //Vector print
template<class T> ostream& operator<<(ostream& o, const set<T>& v){ o<<"[";forstl(it,v)o<<*it<<", ";return o<<"]";} //Set print
template<class T> inline void MAX(T &a , T b){ if (a < b ) a = b;}
template<class T> inline void MIN(T &a , T b){ if (a > b ) a = b;}

//Fast Reader
template<class T>inline bool read(T &x){int c=gc();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=gc();}for(x=0;~c&&'0'<=c&&c<='9';c=gc())x=x*10+c-'0';x*=sgn;return ~c;}

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction

int main(){
    int n ;
    string s ;
    while( cin >> n >> s ) {
        if( n == 2 || n == 3 ) { cout << s << endl ; continue ; }
        if( n % 2 == 0 ) {
            string ans ;
            int c = 0 ;
            rep(i,n) {
                c++ ;
                if( c == 2 ) {
                    ans = ans + s[i-1] + s[i];
                    c = 0 ;
                    ans += '-';
                }
            }
            int len = ans.size() ;
            rep(i,len-1) cout << ans[i] ;
            cout  << endl;
        }
        else {
           string x ;
           for(  int i = 3 ; i < n ; i++ ) x += s[i] ;
           rep(i,3) cout << s[i] ;
           cout << '-';
           s = x ;
           n = x.size() ;
           string ans ;
            int c = 0 ;
            rep(i,n) {
                c++ ;
                if( c == 2 ) {
                    ans = ans + s[i-1] + s[i];
                    c = 0 ;
                    ans += '-';
                }
            }
            int len = ans.size() ;
            rep(i,len-1) cout << ans[i] ;
            cout  << endl;
        }
    }
}


#include <string>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <fstream>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

typedef tuple<ll,ll> int2;
typedef tuple<ll,ll,ll> int3;
typedef tuple<ll,ll,ll,ll> int4;

#define all(v) (v).begin(), (v).end()
#define est(v,e) (find(all(v), (e)) != (v).end())
#define pb push_back
#define eb emplace_back
#define SZ(a) ((ll)((a).size()))
#define For(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) For(i,0,n)
#define tag(i,v) rep(i,SZ(v))
#define trace(x)  cerr << #x << " = " << (x) << endl
#define tracev(x) cerr << #x << " = "; tag(__i, x) { cerr << x[__i] << ","; } cerr << endl
#define initv(typ, v, n) vector<typ> v; rep(i,n) { typ tmp; cin >> tmp; x.pb(tmp); }
#define fst get<0>
#define snd get<1>
#define thd get<2>

const ll inf = 1LL << 60;
int toInt(string s) {int res;stringstream ss;ss<<s;ss>>res;return res;}

int main(void) {

  #define int long long

  #ifdef ONLINE_JUDGE
  ifstream ifile("input.txt");
  if(ifile) freopen("input.txt", "rt", stdin);
  if(ifile) freopen("output.txt", "wt", stdout);
  #endif

  int n;
  cin >> n;

  rep(i,3){

    int x,y;
    cin >> x >> y;

    if(x==n)n=y;
    else if(y==n)n=x;

  }

  cout << (n) << endl;

  return 0;

}


#include<bits/stdc++.h>
using namespace std;
int main()
 {
     char a[8][8];
     int rows=0,col=0;
     for (int i=0;i<8;i++)
      {
          int ans=0;
          for (int j=0;j<8;j++)
           {
               cin>>a[i][j];
               if (a[i][j]=='B') ans++;
              // cout<<ans<<"\n";
           }
           if (ans==8) rows++;

           else col=ans;

      }
     cout<<col+rows<<"\n";
 }

[{'input': 'WWWBWWBW\r\nBBBBBBBB\r\nWWWBWWBW\r\nWWWBWWBW\r\nWWWBWWBW\r\nWWWBWWBW\r\nWWWBWWBW\r\nWWWBWWBW\r\n', 'output': ['3']}, {'input': 'WWWWWWWW\r\nBBBBBBBB\r\nWWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\n', 'output': ['1']}, {'input': 'WWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\nWWWWWWWW\r\n', 'output': ['0']}, {'input': 'BBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\n', 'output': ['8']}, {'input': 'BBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBW\r\n', 'output': ['14']}, {'input': 'BBBBBBBB\r\nBBBBBBBB\r\nBBBBBBWB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\n', 'output': ['14']}, {'input': 'BBBBBBBB\r\nWBBBWBBW\r\nBBBBBBBB\r\nWBBBWBBW\r\nWBBBWBBW\r\nBBBBBBBB\r\nBBBBBBBB\r\nWBBBWBBW\r\n', 'output': ['9']}, {'input': 'BBBBBBBB\r\nWBBWWWBB\r\nBBBBBBBB\r\nWBBWWWBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nWBBWWWBB\r\nBBBBBBBB\r\n', 'output': ['9']}, {'input': 'BBBBBWWB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBWWB\r\nBBBBBWWB\r\nBBBBBWWB\r\nBBBBBWWB\r\nBBBBBWWB\r\n', 'output': ['8']}, {'input': 'WWWWBBBB\r\nWWWWBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nWWWWBBBB\r\nWWWWBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\n', 'output': ['8']}, {'input': 'BBBBBBBB\r\nWBWWBBBW\r\nBBBBBBBB\r\nWBWWBBBW\r\nWBWWBBBW\r\nWBWWBBBW\r\nWBWWBBBW\r\nBBBBBBBB\r\n', 'output': ['7']}, {'input': 'WBWWBBBW\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nWBWWBBBW\r\nWBWWBBBW\r\n', 'output': ['9']}, {'input': 'BBWWBBBW\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBWWBBBW\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\n', 'output': ['11']}, {'input': 'WWBWBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nWWBWBBBB\r\nBBBBBBBB\r\nWWBWBBBB\r\nBBBBBBBB\r\n', 'output': ['10']}, {'input': 'BBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nWWBWBBBB\r\nWWBWBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nWWBWBBBB\r\n', 'output': ['10']}, {'input': 'WBBWBBBW\r\nWBBWBBBW\r\nWBBWBBBW\r\nWBBWBBBW\r\nWBBWBBBW\r\nBBBBBBBB\r\nWBBWBBBW\r\nWBBWBBBW\r\n', 'output': ['6']}, {'input': 'BBBWBBBW\r\nBBBWBBBW\r\nBBBWBBBW\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBWBBBW\r\nBBBBBBBB\r\nBBBBBBBB\r\n', 'output': ['10']}, {'input': 'BBBBBBBB\r\nBBBWBBBB\r\nBBBWBBBB\r\nBBBWBBBB\r\nBBBBBBBB\r\nBBBWBBBB\r\nBBBWBBBB\r\nBBBWBBBB\r\n', 'output': ['9']}, {'input': 'BBBBBBBB\r\nWWWBBBBB\r\nWWWBBBBB\r\nBBBBBBBB\r\nWWWBBBBB\r\nWWWBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\n', 'output': ['9']}, {'input': 'WBBBBBWB\r\nBBBBBBBB\r\nWBBBBBWB\r\nWBBBBBWB\r\nWBBBBBWB\r\nWBBBBBWB\r\nWBBBBBWB\r\nBBBBBBBB\r\n', 'output': ['8']}, {'input': 'WBBBWWBW\r\nWBBBWWBW\r\nBBBBBBBB\r\nWBBBWWBW\r\nBBBBBBBB\r\nWBBBWWBW\r\nWBBBWWBW\r\nWBBBWWBW\r\n', 'output': ['6']}, {'input': 'WBBBBWBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nWBBBBWBB\r\nWBBBBWBB\r\nBBBBBBBB\r\nWBBBBWBB\r\nBBBBBBBB\r\n', 'output': ['10']}, {'input': 'BBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nWBBBWBBW\r\nBBBBBBBB\r\nBBBBBBBB\r\nWBBBWBBW\r\nBBBBBBBB\r\n', 'output': ['11']}, {'input': 'BBBBBBBB\r\nBWBBBBBW\r\nBWBBBBBW\r\nBBBBBBBB\r\nBWBBBBBW\r\nBWBBBBBW\r\nBBBBBBBB\r\nBWBBBBBW\r\n', 'output': ['9']}, {'input': 'BBBBBBBB\r\nBBBBBBBB\r\nWBBBWWWW\r\nBBBBBBBB\r\nBBBBBBBB\r\nWBBBWWWW\r\nBBBBBBBB\r\nBBBBBBBB\r\n', 'output': ['9']}, {'input': 'BWBBBWWB\r\nBWBBBWWB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBWBBBWWB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\n', 'output': ['10']}, {'input': 'BBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBWBBWBWB\r\n', 'output': ['12']}, {'input': 'BWBBBBWW\r\nBWBBBBWW\r\nBWBBBBWW\r\nBWBBBBWW\r\nBBBBBBBB\r\nBWBBBBWW\r\nBWBBBBWW\r\nBBBBBBBB\r\n', 'output': ['7']}, {'input': 'WWBBWWBB\r\nBBBBBBBB\r\nWWBBWWBB\r\nWWBBWWBB\r\nWWBBWWBB\r\nBBBBBBBB\r\nWWBBWWBB\r\nWWBBWWBB\r\n', 'output': ['6']}, {'input': 'BWBBWWWW\r\nBWBBWWWW\r\nBWBBWWWW\r\nBBBBBBBB\r\nBBBBBBBB\r\nBBBBBBBB\r\nBWBBWWWW\r\nBBBBBBBB\r\n', 'output': ['7']}]


#include<bits/stdc++.h>
using namespace std;
int main(){
    int r,c;
    string s;
    cin>>r>>c;
   // vector<string>v;
    //for(int i=0;i<r;i++){
        //cin>>s;
        //v.push_back(s);
    //}
    char v[r][c];
    for(int i=0;i<r;i++){
        cin>>v[i];
    }
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            bool flag = true;
            for(int h=0;h<r;h++){
                if(v[h][j]==v[i][j]&&h!=i){
                    flag  = false;
                    //cout<<h<<" "<<j<<endl;
                }
            }
            for(int h=0;h<c;h++){
                if(v[i][h]==v[i][j]&&h!=j){
                    flag  = false;
                    //cout<<j<<" "<<h<<endl;
                }
            }
            if(flag == true){
                //cout<<i<<" "<<j<<endl;
                cout<<v[i][j];
            }
        }
    }
    cout<<endl;
    return 0;
}

[{'input': '3 3\r\ncba\r\nbcd\r\ncbc\r\n', 'output': ['abcd']}, {'input': '5 5\r\nfcofd\r\nooedo\r\nafaoa\r\nrdcdf\r\neofsf\r\n', 'output': ['codeforces']}, {'input': '4 4\r\nusah\r\nusha\r\nhasu\r\nsuha\r\n', 'output': ['ahhasusu']}, {'input': '7 5\r\naabcd\r\neffgh\r\niijkk\r\nlmnoo\r\npqqrs\r\nttuvw\r\nxxyyz\r\n', 'output': ['bcdeghjlmnprsuvwz']}, {'input': '10 10\r\naaaaaaaaaa\r\nbccceeeeee\r\ncdfffffffe\r\ncdfiiiiile\r\ncdfjjjjile\r\ndddddddile\r\nedfkkkkile\r\nedddddddde\r\ngggggggggg\r\nhhhhhhhhhe\r\n', 'output': ['b']}, {'input': '15 3\r\njhg\r\njkn\r\njui\r\nfth\r\noij\r\nyuf\r\nyfb\r\nugd\r\nhgd\r\noih\r\nhvc\r\nugg\r\nyvv\r\ntdg\r\nhgf\r\n', 'output': ['hkniftjfbctd']}, {'input': '17 19\r\nbmzbmweyydiadtlcoue\r\ngmdbyfwurpwbpuvhifn\r\nuapwyndmhtqvkgkbhty\r\ntszotwflegsjzzszfwt\r\nzfpnscguemwrczqxyci\r\nvdqnkypnxnnpmuduhzn\r\noaquudhavrncwfwujpc\r\nmiggjmcmkkbnjfeodxk\r\ngjgwxtrxingiqquhuwq\r\nhdswxxrxuzzfhkplwun\r\nfagppcoildagktgdarv\r\neusjuqfistulgbglwmf\r\ngzrnyxryetwzhlnfewc\r\nzmnoozlqatugmdjwgzc\r\nfabbkoxyjxkatjmpprs\r\nwkdkobdagwdwxsufees\r\nrvncbszcepigpbzuzoo\r\n', 'output': ['lcorviunqvgblgjfsgmrqxyivyxodhvrjpicbneodxjtfkpolvejqmllqadjwotmbgxrvs']}, {'input': '1 1\r\na\r\n', 'output': ['a']}, {'input': '2 2\r\nzx\r\nxz\r\n', 'output': ['zxxz']}, {'input': '1 2\r\nfg\r\n', 'output': ['fg']}, {'input': '2 1\r\nh\r\nj\r\n', 'output': ['hj']}, {'input': '1 3\r\niji\r\n', 'output': ['j']}, {'input': '3 1\r\nk\r\np\r\nk\r\n', 'output': ['p']}, {'input': '2 3\r\nmhw\r\nbfq\r\n', 'output': ['mhwbfq']}, {'input': '3 2\r\nxe\r\ner\r\nwb\r\n', 'output': ['xeerwb']}, {'input': '3 7\r\nnutuvjg\r\ntgqutfn\r\nyfjeiot\r\n', 'output': ['ntvjggqfnyfjeiot']}, {'input': '5 4\r\nuzvs\r\namfz\r\nwypl\r\nxizp\r\nfhmf\r\n', 'output': ['uzvsamfzwyplxizphm']}, {'input': '8 9\r\ntjqrtgrem\r\nrwjcfuoey\r\nywrjgpzca\r\nwabzggojv\r\najqmmcclh\r\nozilebskd\r\nqmgnbmtcq\r\nwakptzkjr\r\n', 'output': ['mrjcfuyyrjpzabzvalhozilebskdgnbtpzr']}, {'input': '9 3\r\njel\r\njws\r\ntab\r\nvyo\r\nkgm\r\npls\r\nabq\r\nbjx\r\nljt\r\n', 'output': ['elwtabvyokgmplabqbxlt']}, {'input': '7 6\r\neklgxi\r\nxmpzgf\r\nxvwcmr\r\nrqssed\r\nouiqpt\r\ndueiok\r\nbbuorv\r\n', 'output': ['eklgximpzgfvwcmrrqedoiqptdeiokuorv']}, {'input': '14 27\r\npzoshpvvjdpmwfoeojapmkxjrnk\r\nitoojpcorxjdxrwyewtmmlhjxhx\r\ndoyopbwusgsmephixzcilxpskxh\r\nygpvepeuxjbnezdrnjfwdhjwjka\r\nrfjlbypoalbtjwrpjxzenmeipfg\r\nkhjhrtktcnajrnbefhpavxxfnlx\r\nvwlwumqpfegjgvoezevqsolaqhh\r\npdrvrtzqsoujqfeitkqgtxwckrl\r\nxtepjflcxcrfomhqimhimnzfxzg\r\nwhkfkfvvjwkmwhfgeovwowshyhw\r\nolchgmhiehumivswgtfyhqfagbp\r\ntdudrkttpkryvaiepsijuejqvmq\r\nmuratfqqdbfpefmhjzercortroh\r\nwxkebkzchupxumfizftgqvuwgau\r\n', 'output': ['zshdanicdyldybwgclygzrhkayatwxznmicbpvlupfsoewcleploqngsyolceswtyqbpyasmuadbpcehqva']}, {'input': '1 100\r\nysijllpanprcrrtvokqmmupuptvawhvnekeybdkzqaduotmkfwybqvytkbjfzyqztmxckizheorvkhtyoohbswcmhknyzlgxordu\r\n', 'output': ['g']}, {'input': '2 100\r\ngplwoaggwuxzutpwnmxhotbexntzmitmcvnvmuxknwvcrnsagvdojdgaccfbheqojgcqievijxapvepwqolmnjqsbejtnkaifstp\r\noictcmphxbrylaarcwpruiastazvmfhlcgticvwhpxyiiqokxcjgwlnfykkqdsfmrfaedzchrfzlwdclqjxvidhomhxqnlmuoowg\r\n', 'output': ['rbe']}, {'input': '3 100\r\nonmhsoxoexfwavmamoecptondioxdjsoxfuqxkjviqnjukwqjwfadnohueaxrkreycicgxpmogijgejxsprwiweyvwembluwwqhj\r\nuofldyjyuhzgmkeurawgsrburovdppzjiyddpzxslhyesvmuwlgdjvzjqqcpubfgxliulyvxxloqyhxspoxvhllbrajlommpghlv\r\nvdohhghjlvihrzmwskxfatoodupmnouwyyfarhihxpdnbwrvrysrpxxptdidpqabwbfnxhiziiiqtozqjtnitgepxjxosspsjldo\r\n', 'output': ['blkck']}, {'input': '100 1\r\na\r\nm\r\nn\r\nh\r\na\r\nx\r\nt\r\na\r\no\r\np\r\nj\r\nz\r\nr\r\nk\r\nq\r\nl\r\nb\r\nr\r\no\r\ni\r\ny\r\ni\r\np\r\ni\r\nt\r\nn\r\nd\r\nc\r\nz\r\np\r\nu\r\nn\r\nw\r\ny\r\ng\r\ns\r\nt\r\nm\r\nz\r\ne\r\nv\r\ng\r\ny\r\nj\r\nd\r\nz\r\ny\r\na\r\nn\r\nx\r\nk\r\nd\r\nq\r\nn\r\nv\r\ng\r\nk\r\ni\r\nk\r\nf\r\na\r\nb\r\nw\r\no\r\nu\r\nw\r\nk\r\nk\r\nb\r\nz\r\nu\r\ni\r\nu\r\nv\r\ng\r\nv\r\nx\r\ng\r\np\r\ni\r\nz\r\ns\r\nv\r\nq\r\ns\r\nb\r\nw\r\ne\r\np\r\nk\r\nt\r\np\r\nd\r\nr\r\ng\r\nd\r\nk\r\nm\r\nf\r\nd\r\n', 'output': ['hlc']}, {'input': '100 2\r\nhd\r\ngx\r\nmz\r\nbq\r\nof\r\nst\r\nzc\r\ndg\r\nth\r\nba\r\new\r\nbw\r\noc\r\now\r\nvh\r\nqp\r\nin\r\neh\r\npj\r\nat\r\nnn\r\nbr\r\nij\r\nco\r\nlv\r\nsa\r\ntb\r\nbl\r\nsr\r\nxa\r\nbz\r\nrp\r\nsz\r\noi\r\nec\r\npw\r\nhf\r\njm\r\nwu\r\nhq\r\nra\r\npv\r\ntc\r\ngv\r\nik\r\nux\r\ntz\r\nbf\r\nty\r\ndk\r\nwo\r\nor\r\nza\r\nkv\r\nqt\r\nfa\r\njy\r\nbk\r\nuv\r\ngk\r\ncz\r\nds\r\nie\r\noq\r\nmf\r\nxn\r\nql\r\nxs\r\nfb\r\niv\r\ncj\r\nkn\r\nns\r\nlg\r\nji\r\nha\r\naj\r\ndg\r\nfj\r\nut\r\nsg\r\nju\r\noc\r\nov\r\nhe\r\nnw\r\nbl\r\nlp\r\nbx\r\nnm\r\nyq\r\ncw\r\nov\r\nxk\r\npg\r\noh\r\npl\r\nuo\r\ngf\r\nul\r\n', 'output': ['dvy']}, {'input': '100 3\r\nruy\r\nmye\r\njgp\r\nscn\r\nktq\r\nalx\r\nmvk\r\nlpm\r\nkry\r\norb\r\nmpu\r\nzcv\r\nlge\r\nkft\r\ndzp\r\ntfb\r\nhqz\r\nuur\r\nhry\r\nzjx\r\ncuo\r\nqqc\r\ntih\r\nenj\r\nvnp\r\nbwi\r\nzzh\r\nhkc\r\nwdr\r\nldh\r\nvel\r\nizj\r\nfhb\r\nqrn\r\nqpp\r\nvzs\r\nlhg\r\nkee\r\nlbq\r\nzhy\r\nwcl\r\nyaa\r\nton\r\nfly\r\nkyw\r\nept\r\ngwq\r\ncoe\r\nopd\r\neez\r\nnmx\r\nnjg\r\nwhy\r\nvel\r\nafq\r\nnbq\r\nulx\r\noxs\r\nbbo\r\nyhx\r\nfmz\r\nnrg\r\nnfm\r\njek\r\nbeu\r\ntya\r\nxgs\r\nsgg\r\nnkq\r\nbbv\r\nwkd\r\ntns\r\nfdt\r\neox\r\nobc\r\neab\r\nkkj\r\noub\r\ngji\r\nrht\r\nozv\r\nysk\r\nsbt\r\nflf\r\npbu\r\nlxb\r\npzs\r\nrzh\r\ncea\r\nkmi\r\nuea\r\nncc\r\nzng\r\nvkn\r\njhn\r\njqw\r\nlqc\r\nmbt\r\nlov\r\ngam\r\n', 'output': ['tvdiixs']}]


#include<bits/stdc++.h>
using namespace std;
int main(){
    int x1,y1;
    cin>>x1>>y1;
    int x2,y2;
    cin>>x2>>y2;
    int a=abs(x2-x1);
    int b=abs(y2-y1);
    if(a>=b){
        cout<<b+a-b<<endl;
    }
    else{
        cout<<a+b-a<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;

int main()
{
	//char  str[1000];
	int k,count;
    string str;
	cin>>str;
	 cin>>k;

   int value=str.length();

  int cnt=0;
	for(int i=97;i<123;i++)
	{  count=0;
		for(int j=0;j<value;j++)
		{
			if(str[j]==i)
				count++;
		}
   if(count>0)
   	cnt++;
	}
  if(k>value)
	{
		cout<<"impossible";
	}
    else if(k<=cnt)
    {
       cout<<"0";
    }
	else
	{    k=k-cnt;
		 cout<<k;
	}
}

[{'input': 'yandex\r\n6\r\n', 'output': ['0\r\n']}, {'input': 'yahoo\r\n5\r\n', 'output': ['1\r\n']}, {'input': 'google\r\n7\r\n', 'output': ['impossible\r\n']}, {'input': 'a\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'z\r\n2\r\n', 'output': ['impossible\r\n']}, {'input': 'fwgfrwgkuwghfiruhewgirueguhergiqrbvgrgf\r\n26\r\n', 'output': ['14\r\n']}, {'input': 'nfevghreuoghrueighoqghbnebvnejbvnbgneluqe\r\n26\r\n', 'output': ['12\r\n']}, {'input': 'a\r\n3\r\n', 'output': ['impossible\r\n']}, {'input': 'smaxpqplaqqbxuqxalqmbmmgubbpspxhawbxsuqhhegpmmpebqmqpbbeplwaepxmsahuepuhuhwxeqmmlgqubuaxehwuwasgxpqmugbmuawuhwqlswllssueglbxepbmwgs\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'cuguccgcugcugucgggggcgcgucgucugcuuuccccuugccg\r\n4\r\n', 'output': ['1\r\n']}, {'input': 'fcfccfcfccfcfcffcffffffcfccfccfcffccccfcffffccfccfcffcfcccccffcfffcccffcfccfffffcccfccffffffccfccccf\r\n20\r\n', 'output': ['18\r\n']}, {'input': 'swmkwaruyv\r\n5\r\n', 'output': ['0\r\n']}, {'input': 'tnbqpsuhkczmejirvyfdolxwga\r\n22\r\n', 'output': ['0\r\n']}, {'input': 'abcde\r\n3\r\n', 'output': ['0\r\n']}, {'input': 'abb\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'aaaa\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'abcde\r\n2\r\n', 'output': ['0\r\n']}, {'input': 'yandex\r\n4\r\n', 'output': ['0\r\n']}, {'input': 'aaabbbccc\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'abcd\r\n2\r\n', 'output': ['0\r\n']}, {'input': 'asdfgh\r\n2\r\n', 'output': ['0\r\n']}, {'input': 'aab\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'mynameissako\r\n5\r\n', 'output': ['0\r\n']}, {'input': 'abcde\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'abcd\r\n3\r\n', 'output': ['0\r\n']}, {'input': 'abcdef\r\n2\r\n', 'output': ['0\r\n']}, {'input': 'abcdefg\r\n4\r\n', 'output': ['0\r\n']}, {'input': 'abc\r\n1\r\n', 'output': ['0\r\n']}, {'input': 'asdafjsgljdllgjdgkl\r\n5\r\n', 'output': ['0\r\n']}, {'input': 'yaay\r\n3\r\n', 'output': ['1\r\n']}, {'input': 'yaay\r\n4\r\n', 'output': ['2\r\n']}, {'input': 'zzzzzz\r\n2\r\n', 'output': ['1\r\n']}]


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int num[105];
int main()
{
   int n;
   scanf("%d",&n);
   int countt=1000;
   int y=0;
   int a,b;
   while(n--)
   { int t=0;
      scanf("%d",&num[y++]);
      if(y>1)
      {
          if(num[y-1]>num[y-2])
          {
             t=num[y-1]-num[y-2];
          }
          else
          {
             t=num[y-2]-num[y-1];
          }
          if(countt>t) {countt=t;a=y-1;b=y;}
      }
   }
   if(num[0]>num[y-1])
   {
     if(countt>(num[0]-num[y-1])) {countt=num[0]-num[y-1];a=y;b=1;}
   }
   else{
    if(countt>(num[y-1]-num[0])) {countt=num[y-1]-num[0];a=y;b=1;}
   }
   printf("%d %d\n",a,b);
    return 0;
}


#include<bits/stdc++.h>
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
// long long int n,m,k,flag=0,sz=0,op[51][51],dx[]={0,0,0,1},dtm[]={1,0,0,0};
// string s[51];
// vector<pair<long long int,pair<long long int,long long int>>>vv;
// void dfschng(long long int x,long long int y)
// {
//  if(x<0 || y<0 || x>=n || y>=m)
//  {
//   return;
//  }
//  if(op[x][y] || s[x][y]=='*')
//  {
//   return;
//  }
//  //cout<<x<<" "<<y<<"\n";
//  op[x][y]=1;s[x][y]='*';
//  for(long long int i=0;i<4;i++)
//  {
//   long long int xx=x+dx[i],yy=y+dtm[i];
//   dfschng(xx,yy);
//  }
// }
// void dfs(long long int x,long long int y)
// {
//  if(x<0 || y<0 || x>=n || y>=m)
//  {
//   return;
//  }
//  if(op[x][y] || s[x][y]=='*')
//  {
//   return;
//  }
//  op[x][y]=1;sz++;
//  if(x==0 || y==0 || x==(n0) || y==(m0))
//  {
//   flag=1;
//  }
//  for(long long int i=0;i<4;i++)
//  {
//   long long int xx=x+dx[i],yy=y+dtm[i];
//   dfs(xx,yy);
//  }
// }
// long long int n;
//  cin>>n;
//  for(long long int i=1;i<=n;i+=2)
//  {
//   cout<<i<<" ";
//  }
//  for(long long int i=n-(n&1);i>=1;i-=2)
//  {
//   cout<<i<<" ";
//  }
//  cout<<"\n";
// struct coord
// {
//  long long int x=0,y=0;
// };
void solve()
{
 long long int n,op=0;
 cin>>n;
 if(n<=3)
 {
  op=n*2-1;
  cout<<op;return;
 }
 for(long long int i=1;;i+=2)
 {
  if((i*i+1)/2>=n)
  {
   op=i;
   break;
  }
 }
 cout<<op;
}
int main()
{
    fast_cin();
    long long int t;
    //cin>>t;
    t=1;
    while(t--)
    {
     solve();
    }
   return 0;
}


#include<bits/stdc++.h>
#define F first
#define S second
#define pii pair<int , int>
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 1e5 + 10;
ll dp[N] , sz[N] , t[N];
vector<pii> a[N];

bool cmp(pair<pair<ll , ll> , int> x , pair<pair<ll , ll >  , int> y){
    ll p1 = x.F.F , p2 = y.F.F , s1 = x.F.S , s2 = y.F.S;
    return p1 * s2 < p2 * s1;
}

void dfs(int v,int p=-1){
    sz[v]++;
    vector<pair<pair<ll , ll >  , int> > childs;
    for(auto X:a[v]){
        int u = X.F , w = X.S;
        if(u == p)continue;
        dfs(u , v);
        sz[v]+=sz[u];
        t[v]+=t[u] + w;
        dp[v]+=w * sz[u] + dp[u];
        childs.pb({{t[u] + w , sz[u]} , u});
    }
    sort(childs.begin() , childs.end() ,cmp);
    ll tim = 0;
    for(auto X:childs){
        ll p = X.F.F , sz = X.F.S , ind = X.S;
        dp[v]+=(ll)2 * tim * sz;
        tim+=p;
    }
    return ;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin>>n;
    for(int i=0;i<n-1;i++){
        int u,v,w; cin>>u>>v>>w;
        a[u].pb({v , w});
        a[v].pb({u , w});
    }
    dfs(1);
    cout<<fixed<<setprecision(12)<<(ld)(dp[1])/(n-1)<<'\n';
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

string s;
int cnt1[11], cnt2[11], res1[100005], res2[100005];

int main() {
    cin>>s;
    for(int i= 0;i<s.size();++i) {
        ++cnt1[s[i]-'0'];
        ++cnt2[s[i]-'0'];
    }
    int res = 0, cntZero = 0, t1 = -1, t2 = -1;
    for(int x = 0;x<=cnt1[0];++x) {
        cnt1[0] -= x;
        cnt2[0] -= x;
        for(int i = 1;i<=5;++i) {
            int j = 10-i;
            if(cnt1[i] && cnt2[j]) {
                --cnt1[i];
                --cnt2[j];
                int numZeroes = x + 1;
                for(int k = 0;k<=9;++k)
                    numZeroes += min(cnt1[k],cnt2[9-k]);
                if(numZeroes > res) {
                    res = numZeroes;
                    cntZero = x;
                    t1 = i;
                    t2 = j;
                }
                ++cnt1[i];
                ++cnt2[j];
            }
        }
        cnt1[0] += x;
        cnt2[0] += x;
    }
    if(t1 == -1 && t2 == -1) {
        sort(s.begin(),s.end());
        reverse(s.begin(),s.end());
        cout<<s<<endl;
        cout<<s<<endl;
        return 0;
    }

    for(int i = 0;i<cntZero;++i)
        res1[i] = res2[i] = 0;
    cnt1[0] -= cntZero;
    cnt2[0] -= cntZero;
    --cnt1[t1];
    --cnt2[t2];
    res1[cntZero] = t1;
    res2[cntZero] = t2;
    for(int i = cntZero+1;i<s.size();++i) {
        bool ok = false;
        for(int j = 0;j<=9;++j) {
            if(cnt1[j] && cnt2[9-j]) {
                --cnt1[j];
                --cnt2[9-j];
                ok = true;
                res1[i] = j;
                res2[i] = 9-j;
                break;
            }
        }
        if(!ok) {
            for(int j = 0;j<=9;++j) {
                if(cnt1[j]) {
                    res1[i] = j;
                    --cnt1[j];
                    break;
                }
            }
            for(int j = 0;j<=9;++j) {
                if(cnt2[j]) {
                    res2[i] = j;
                    --cnt2[j];
                    break;
                }
            }
        }
    }

    for(int i = s.size()-1;i>=0;--i)
        printf("%d",res1[i]);
    printf("\n");
    for(int i = s.size()-1;i>=0;--i)
        printf("%d",res2[i]);
    printf("\n");

    return 0;
}


#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include "vector"

// getline(cin, string);
//memset(memo, -1, sizeof memo); // initialize DP memoization table with -1
//memset(arr, 0, sizeof arr); // to clear array of integers
using namespace std;
#define F first
#define S second
#define ll long long
#define PB push_back
#define MP make_pair
#define all(v) v.begin(), v.end()
#define sz(v) ((int)((v).size()))
#define f(i, n) for(ll i=0; i < n; i++)
#define oo 1e17+5
typedef vector<int> vi;
typedef set<string> ss;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<long long> vll;
typedef long double   	  ld;
typedef vector<double>    vd;
typedef vector<vi>      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;

const ll M = 998244353;
const ll MAX = 1e18;
const ld EPS {1e-19};
const ld PI {3.14159265358979323846};
ll pow(ll x, ll y) {
    ll ans{1};
    while(y) {
        if(y&1) ans *= x;
        x *= x;
        y /= 2;
    }
    return ans;
}
ll big_pow(ll x, ll y) {
    ll ans{1};
    while(y) {
        if(y&1) ans = ((ans%M)*(x%M)) % M;
        x = ((x%M) * (x%M)) %M;
        y/=2;
    }
    return ans;
}
bool is_int(ld num) {
    return num == (ll)num;
}
int cmp_d(ld a, ld b) {
    if(fabs(a-b) <= EPS) return -1;
    return a>b? 1:0;
}
ll mod(ll x, ll m){
    return (x%m +m) % m;
}

void printVec(const vi& v, string t =""){
    cout << t;
    for(auto i = v.begin(); i!= v.end(); i++) {
        cout << *i <<" ";
//        if(i != v.end() -1) cout << " ";
    }
    cout <<"\n";
}

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

ll mod_pow(ll b, ll p, ll m) {
    if(!p) return 1;

    ll ans = mod_pow(b,p/2,m);
    ans = mod(ans*ans,m);

    if(p&1) ans = mod(ans*b,m);
    return ans;
}
// M is a prime number > N
ll inv(ll a) {     // Fermat's little theorem
    return mod_pow(a,M-2,M); // O(log p)
}

unsigned ll C(unsigned ll n, unsigned ll k, unsigned ll fact[]){
    return ( ((fact[n] * inv(fact[k]))%M) * inv(fact[n-k]) ) % M;
}
struct comp {
    template <typename T>
    bool operator()(const T& p1, const T& p2) const
    {
        if(p1.second != p2.second) return p1.second < p2.second;
        else return p1.first < p1.first;
    }
};

double dist(ld x, ld y, ii p2){
    return sqrt(pow((x - p2.F), 2) + pow((y- p2.S), 2));
}

struct P {
    ll x, y, z;
    bool operator<(const P &p) const {
        if(x != p.x) return x <  p.x;
        else return y <  p.y;
    }
};

const ll N = 1e2+2;
bool vis[N];
vector<vi> v(N);

void dfs(double p,ll i ,ll l){
    vis[i] = 1;
    ll nnv= 0;
    for(auto x: v[i]){
        if(!vis[x]) nnv++;
    }
    if(nnv) p /= (double) (nnv);
    for(auto x: v[i]){
        if(!vis[x]) {
            dfs(p, x, l+1);
        }
    }
}

ll mem[N][N][3];
ll k1, k2;
ll dp(ll n1, ll n2, int f){
    if(n1 == 0 && n2 == 0) return 1;
    else if (n1 < 0 || n2 < 0) return 0;
    if(mem[n1][n2][f] != -1) return mem[n1][n2][f];

    ll nways = 0;
    if(f != 1){
        for(int i = 1; i <= k1; i++){
            if(n1 - i < 0) break;
            nways += dp(n1 - i, n2, 1);
        }
    }

    if(f != 0){
        for(int i = 1; i <= k2; i++){
            if(n2 - i < 0) break;
            nways += dp(n1, n2- i, 0);
        }
    }

    mem[n1][n2][f] = nways % 100000000;
    return mem[n1][n2][f];

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x1, y1, r1, R1, x2, y2, r2, R2;
    cin>> x1 >> y1 >> r1 >> R1;
    cin>> x2 >> y2 >> r2 >> R2;
    ll cnt =0;
    ld c1c2 = dist(x1, y1, MP(x2, y2));

    bool ch11 =0, ch1 = 0, ch22 = 0, ch2 = 0;
    if(abs(r2 - r1) >= c1c2) ch11 = 1;
    else if(c1c2 >= r2 + r1) ch1 = 1;
    if(abs(R2 - r1) >= c1c2) ch22 = 1;
    else if(c1c2 >= R2 + r1) ch2 = 1;
    if((ch1 || ch11) && (ch2 || ch22)){
        if(ch11 && ch22){ if((r2 - r1) * (R2 - r1) > 0) cnt++;}
        else if(ch1 && ch2) cnt++;
    }
//    cout << cnt<<"\n";

    ch11 =0, ch1 = 0, ch22 = 0, ch2 = 0;
    if(abs(r2 - R1) >= c1c2) ch11 = 1;
    else if(c1c2 >= r2 + R1) ch1 = 1;
    if(abs(R2 - R1) >= c1c2) ch22 = 1;
    else if(c1c2 >= R2 + R1) ch2 = 1;
    if((ch1 || ch11) && (ch2 || ch22)){
        if(ch11 && ch22) {if(((r2 - R1) * (R2 - R1) > 0)) cnt++; }
        else if(ch1 && ch2) cnt++;
    }
//    cout << cnt<<"\n";

    ch11 =0, ch1 = 0, ch22 = 0, ch2 = 0;
    if(abs(r2 - r1) >= c1c2) ch11 = 1;
    else if(c1c2 >= r1 + r2) ch1 = 1;
    if(abs(r2 - R1) >= c1c2) ch22 = 1;
    else if(c1c2 >= R1 + r2) ch2 = 1;
    if((ch1 || ch11) && (ch2 || ch22)){
        if(ch11 && ch22) { if((r1 - r2) * (R1 - r2) > 0) cnt++; }
        else if(ch1 && ch2) cnt++;
    }
//    cout << cnt<<"\n";

    ch11 =0, ch1 = 0, ch22 = 0, ch2 = 0;
    if(abs(R2 - r1) >= c1c2) ch11 = 1;
    else if(c1c2 >= r1 + R2) ch1 = 1;
    if(abs(R2 - R1) >= c1c2) ch22 = 1;
    else if(c1c2 >= R1 + R2) ch2 = 1;
    if((ch1 || ch11) && (ch2 || ch22)){
        if(ch11 && ch22) { if((r1 - R2) * (R1 - R2) > 0) cnt++; }
        else if(ch1 && ch2) cnt++;
    }
    cout << cnt;
}


#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <math.h>
#include <stack>
#include <deque>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <list>
#include <bitset>
#define mpair make_pair
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const ld epsylon = 1e-9;
int st1[1024],sz1;
int st2[1024],sz2;
struct ivo{
    int dad[1024];
    int rank[1024];
    vector<bitset<1024> > keys;
    ivo(int n){
        keys.resize(n);
        for(int i=0;i<n;i++){
            dad[i] = i;
            rank[i] = 1;
        }
    }
    bool insame(int x,int y){
        sz1 = 0;
        sz2 = 0;
        while(dad[x]!=x){
            st1[sz1++] = x;
            x = dad[x];
        }
        st1[sz1++] = x;
        while(dad[y]!=y){
            st2[sz2++] = y;
            y= dad[y];
        }
        st2[sz2++] = y;
        return st1[sz1-1] == st2[sz2-1];
    }
    bool join(int x, int y){
        if(insame(x,y)) return false;
        int r1 = st1[sz1-1];
        int r2 = st2[sz2-1];
        if(rank[r1] <= rank[r2]){
            for(int i=0;i<sz1;i++){
                dad[st1[i]] = r2;
            }
            if(rank[r1]==rank[r2]){
                rank[r2]++;
            }
            keys[r2] |= keys[r1];
        } else{
            for(int i=0;i<sz2;i++){
                dad[st2[i]] = r1;
            }
            keys[r1] |= keys[r2];
        }
        return true;
    }
};
vector<pair<int,int> > d;
struct temp{
    int staq;
    string name;
    vector<int> keys;
};
int n;
pair<vector<int>, vector<bitset<1024> > > solve(const vector<temp>& a){
    //int n = (int)a.size();
    int nt = a.size();
    int m = (int)d.size();
    ivo q(n);
    for(int i=0;i<a.size();i++){
        int st = a[i].staq;
        for(int j=0;j<a[i].keys.size();j++){
            q.keys[st][a[i].keys[j]] = 1;
        }
    }
    bool added = true;
    vector<int> opened(m,-1);
    while(added){
        added = false;
        for(int i=0;i<m;i++){
            if(opened[i] != -1) continue;
            int x = d[i].first;
            int y = d[i].second;
            while(q.dad[x] != x) x = q.dad[x];
            while(q.dad[y] != y) y = q.dad[y];

            if(q.keys[x][i] || q.keys[y][i]){
                opened[i] = 1;
                q.join(x,y);
                added = true;
            }
        }
    }
    vector<int> res(n);
    map<int,int> w;
    vector<bitset<1024> > rr;
    int idx = 0;
    for(int i=0;i<n;i++){
        if(q.dad[i] == i){
            if(w.count(i) == 0){
                w[i] = idx;
                res[i] = idx;
                idx++;
                rr.push_back(q.keys[i]);
                continue;
            }else{
                res[i] = w[i];
            }
            continue;
        }
        int temp = i;
        while(q.dad[temp]!=temp){
            temp = q.dad[temp];
        }
        if(w.count(temp) == 0){
            w[temp] = idx;
            res[i] = idx;
            rr.push_back(q.keys[temp]);
            idx++;
        }else{
            res[i] = w[temp];
        }
    }
    return mpair(res,rr);
}
char buf[100];
int main()
{
    //freopen("ivo.in","r",stdin);

    int m,k;
    cin >> n>>m>>k;
    d.resize(m);
    for(int i=0;i<m;i++){
        scanf("%d %d",&d[i].first,&d[i].second);
        d[i].first--;
        d[i].second--;
    }
    vector<temp> a(k);
    for(int i=0;i<k;i++){
        scanf("%s",buf);
        a[i].name = buf;
        int l;
        scanf("%d %d",&a[i].staq,&l);
        a[i].staq--;
        a[i].keys.resize(l);
        for(int j=0;j<l;j++){
            scanf("%d",&a[i].keys[j]);
            a[i].keys[j]--;
        }
    }
    pair<vector<int>, vector<bitset<1024> > > sol1 = solve(a);
    vector<temp> b(k);
    for(int i=0;i<k;i++){
        scanf("%s",buf);
        b[i].name = buf;
        int l;
        scanf("%d %d",&b[i].staq,&l);
        b[i].staq--;
        b[i].keys.resize(l);
        for(int j=0;j<l;j++){
            scanf("%d",&b[i].keys[j]);
            b[i].keys[j]--;
        }
    }
    pair<vector<int>, vector<bitset<1024> > > sol2 = solve(b);
    if(sol1 != sol2){
        cout << "NO\n";
        return 0;
    }
    map<string, int> c1,c2;
    for(int i=0;i<(int)a.size();i++){
        c1[a[i].name] = sol1.first[a[i].staq];
    }
    for(int i=0;i<(int)b.size();i++){
        c2[b[i].name] = sol2.first[b[i].staq];
    }
    if(c1 == c2){
        cout << "YES\n";
        return 0;
    }
    cout << "NO\n";
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=1010;
double dp[MAXN][MAXN];
int b,w;
int main()
{
	scanf("%d%d",&w,&b);
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=w;i++)
	{
		dp[i][0]=1;
	}
	for(int i=1;i<=w;i++)
	{
		for(int j=1;j<=b;j++)
		{
			dp[i][j]+=(double)i/(i+j);
			if(j>=3)
			{
				dp[i][j]+=dp[i][j-3]*(double)j/(i+j)*((double)(j-1)/(i+j-1))*((double)(j-2)/(i+j-2));
			}
			if(j>=2)
			{
				dp[i][j]+=dp[i-1][j-2]*(double)j/(i+j)*((double)(j-1)/(i+j-1))*((double)i/(i+j-2));
			}
		}
	}
	printf("%.9f\n",dp[w][b]);
}


#include<bits/stdc++.h>
using namespace std;
int type[2505];
int rymic(string s1,string s2,string s3,string s4,int k)
{
    int i,j,cnt,check;
    if(k==0)
    {
    	return 0;
	}
    cnt=0;
    check=0;
    for(j=s1.length()-1;j>=0;j--)
    {
        if(s1[j]=='a' or s1[j]=='e' or s1[j]=='i' or s1[j]=='o' or s1[j]=='u')
        cnt++;
        if(cnt==k)
        {
			check=1;
            break;
        }
    }
    if(check==0)
	{
		return 0;
	}
    s1=s1.substr(j);
	cnt=0;
    check=0;
    for(j=s2.length()-1;j>=0;j--)
    {
        if(s2[j]=='a' or s2[j]=='e' or s2[j]=='i' or s2[j]=='o' or s2[j]=='u')
        cnt++;
        if(cnt==k)
        {
			check=1;
            break;
        }
    }
    if(check==0)
    {
    	return 0;
	}
    s2=s2.substr(j);
    cnt=0;
    check=0;
    for(j=s3.length()-1;j>=0;j--)
    {
        if(s3[j]=='a' or s3[j]=='e' or s3[j]=='i' or s3[j]=='o' or s3[j]=='u')
        {
        	cnt++;
		}
        if(cnt==k)
        {
        	check=1;
            break;
        }
    }
    if(check==0)
    {
    	return 0;
	}
    s3=s3.substr(j);
    cnt=0;
    check=0;
    for(j=s4.length()-1;j>=0;j--)
    {
        if(s4[j]=='a' or s4[j]=='e' or s4[j]=='i' or s4[j]=='o' or s4[j]=='u')
        {
        	cnt++;
		}
        if(cnt==k)
        {
			check=1;
            break;
        }
    }
    if(check==0)
    {
    	return 0;
	}
    s4=s4.substr(j);
    if(s1==s2 and s2==s3 and s3==s4)
    {
        return 4;
	}
    if(s1==s2 and s3==s4)
    {
        return 1;//aabb
	}
    if(s1==s3 and s2==s4)
    {
        return 2;//abab
	}
    if(s1==s4 and s2==s3)
    {
        return 3;
	}
    return 0;//abba
}
int main()
{
    int n,k,i;
    string s1,s2,s3,s4;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>s1>>s2>>s3>>s4;
        type[i]=rymic(s1,s2,s3,s4,k);
    }
	int tmp[5]={0};
    for(i=0;i<n;i++)
	{
		tmp[type[i]]++;
	}
    if(tmp[4]==n)
    {
      	cout<<"aaaa";
	}
    else if(tmp[1]+tmp[4]==n)
    {
    	cout<<"aabb";
	}
    else if(tmp[2]+tmp[4]==n)
    {
    	cout<<"abab";
	}
    else if(tmp[3]+tmp[4]==n)
    {
    	cout<<"abba";
	}
    else
    {
    	cout<<"NO";
	}
	return 0;
}

[{'input': '1 1\r\nday\r\nmay\r\nsun\r\nfun\r\n', 'output': ['aabb\r\n']}, {'input': '1 1\r\nday\r\nmay\r\ngray\r\nway\r\n', 'output': ['aaaa\r\n']}, {'input': '2 1\r\na\r\na\r\na\r\na\r\na\r\na\r\ne\r\ne\r\n', 'output': ['aabb\r\n']}, {'input': '2 1\r\nday\r\nmay\r\nsun\r\nfun\r\ntest\r\nhill\r\nfest\r\nthrill\r\n', 'output': ['NO\r\n']}, {'input': '2 5\r\na\r\na\r\na\r\na\r\na\r\na\r\ne\r\ne\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\nrezwbgy\r\nxakgmv\r\njogezwbgy\r\napezwbgy\r\n', 'output': ['NO\r\n']}, {'input': '2 1\r\nnuqfxwrb\r\napqfkw\r\nuqfxwrb\r\nnhcuqfxwrb\r\nogkznwncmt\r\nevf\r\nogkznwncmt\r\nogkznwncmt\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\naawjvkxx\r\nawjvkxx\r\nxawjvkxx\r\nawjvkxx\r\n', 'output': ['aaaa\r\n']}, {'input': '2 2\r\nrhcujgxabk\r\nnjgdqpurul\r\nueoedt\r\ncpcfhbyvo\r\nzmfwnieog\r\npkpylassbf\r\nhrfeod\r\ncdwuil\r\n', 'output': ['NO\r\n']}, {'input': '2 1\r\nol\r\nol\r\nol\r\nzol\r\nek\r\nek\r\nek\r\nqek\r\n', 'output': ['aaaa\r\n']}, {'input': '3 2\r\nexdaoao\r\nrdwunurp\r\ndunurp\r\ntyqzuxao\r\ndupocgsps\r\nzsiravcm\r\nnqiravcm\r\nlnupocgsps\r\niwashk\r\neepkqcykbv\r\nyviwashk\r\neepkqcykbv\r\n', 'output': ['NO\r\n']}, {'input': '2 1\r\ndaihacbnhgfts\r\nsqihpntjvczkw\r\nmihpntjvczkw\r\nvyacbnhgfts\r\ntsvovdpqajmgvcj\r\ncexqkwrvctomb\r\njxbomb\r\ngnpajmgvcj\r\n', 'output': ['abba\r\n']}, {'input': '3 2\r\netba\r\ntfecetba\r\nzkitbgcuuy\r\nuuy\r\nbuxeoi\r\nmekxoi\r\nblviwoehy\r\niwoehy\r\njyfpaqntiz\r\nqvaqntiz\r\nhciak\r\niak\r\n', 'output': ['aabb\r\n']}, {'input': '4 3\r\niixxiojrrdytjcbkvymw\r\nbjqixxiojrrdytjcbkvymw\r\nogjixxiojrrdytjcbkvymw\r\nevixxpfxpgicpg\r\njkotitixiughfhphliuurx\r\ngyubkqtonejprfjzvqxbdpn\r\ndpudxfoqnhekjytbwiuurx\r\noubkqtonejprfjzvqxbdpn\r\npgzaendrxjhsfzjmijv\r\npomuaendrxjhsfzjmijv\r\nafyuyxueaendrxjhsfzjmijv\r\naendrxjhsfzjmijv\r\nyubweicj\r\ntbnsuxqigmxdfnmbipubweicj\r\nfuftydlmoo\r\nmdkuftydlmoo\r\n', 'output': ['NO\r\n']}, {'input': '5 2\r\nqurcmcbxyoddgyyccsmb\r\nlsdzsqoa\r\neurcmcbxyoddgyyccsmb\r\noa\r\nutyxmdhcvaclynmstwsx\r\nmkyycelbmkmdrilmbvr\r\nutyxmdhcvaclynmstwsx\r\nrduyelbmkmdrilmbvr\r\nhmguhvqswwciowwgu\r\nnoe\r\nzmyncuwrowwgu\r\nqrhymghavvbmigzsjoe\r\nbvofhknbzusykztlxwms\r\nbpbfmvjaimkdeddy\r\neofhknbzusykztlxwms\r\nmhivpkxkpazimkdeddy\r\negvywnhmfngllaknmn\r\nmblkvhenlggoftwjgk\r\nzegvywnhmfngllaknmn\r\ngrdenlggoftwjgk\r\n', 'output': ['abab\r\n']}, {'input': '7 3\r\nferwljzwakxedlgwl\r\noerwljzwakxedlgwl\r\nhyqombizhuhxedprb\r\netptjrizhuhxedprb\r\nurtuckar\r\ndkartmwramklcmi\r\nrurtuckar\r\nnurartmwramklcmi\r\niraziomsv\r\nsaziomsv\r\nbprapiqpayzurgij\r\nusyemayzurgij\r\nztstmeecvmkvuu\r\nquexlecvmkvuu\r\nrlhwecvmkvuu\r\nzecvmkvuu\r\niikymgbncljtub\r\nqiikymgbncljtub\r\nbcavhexqamyszgfya\r\nojexqamyszgfya\r\nieyxqinjinjv\r\nxtiudieyxqinjinjv\r\nthtceyxqinjinjv\r\nmuneyxqinjinjv\r\nwreae\r\nqylcjhjzfhteae\r\nozcjthgyuchqo\r\nfcjozcjthgyuchqo\r\n', 'output': ['NO\r\n']}, {'input': '16 1\r\ni\r\ni\r\ni\r\ni\r\ni\r\nu\r\ni\r\ni\r\no\r\na\r\na\r\no\r\na\r\ni\r\na\r\na\r\ni\r\ni\r\no\r\no\r\ni\r\ni\r\ni\r\ni\r\nu\r\nu\r\nu\r\nu\r\no\r\ne\r\ne\r\ne\r\no\r\ni\r\no\r\ni\r\na\r\na\r\na\r\na\r\nu\r\no\r\no\r\nu\r\ni\r\no\r\no\r\ni\r\na\r\na\r\ne\r\ne\r\na\r\na\r\na\r\na\r\na\r\no\r\na\r\na\r\nu\r\na\r\nu\r\nu\r\n', 'output': ['NO\r\n']}, {'input': '16 1\r\neb\r\neb\r\nfe\r\nce\r\ner\r\ner\r\new\r\new\r\nu\r\ncu\r\nu\r\nu\r\nud\r\nik\r\nud\r\nik\r\nve\r\niw\r\niw\r\nne\r\nel\r\nob\r\nel\r\nob\r\no\r\neo\r\no\r\nyo\r\nav\r\nav\r\nei\r\nmi\r\nu\r\noh\r\noh\r\nzu\r\niw\r\niw\r\na\r\nma\r\ni\r\nu\r\nku\r\ngi\r\nac\r\no\r\no\r\nac\r\ni\r\ner\r\nai\r\ner\r\nyu\r\nuf\r\nuf\r\nhu\r\nef\r\nef\r\nef\r\nef\r\nmu\r\nu\r\nqe\r\nie\r\n', 'output': ['NO\r\n']}, {'input': '25 1\r\nw\r\ni\r\nv\r\nx\r\nh\r\ns\r\nz\r\ny\r\no\r\nn\r\nh\r\ni\r\nf\r\nf\r\ny\r\nr\r\nb\r\nu\r\no\r\np\r\nz\r\nh\r\nt\r\no\r\nw\r\nx\r\nh\r\no\r\nj\r\ny\r\nw\r\nj\r\ny\r\nh\r\nh\r\nr\r\ns\r\nb\r\ny\r\nr\r\nw\r\no\r\nl\r\nl\r\nh\r\nh\r\nw\r\nu\r\na\r\nv\r\no\r\nx\r\nd\r\nw\r\nc\r\nf\r\ni\r\ne\r\nj\r\nq\r\nk\r\na\r\ne\r\nl\r\nw\r\nm\r\nf\r\na\r\nc\r\na\r\nb\r\nf\r\nj\r\nb\r\nx\r\ni\r\nx\r\ne\r\nu\r\nh\r\nm\r\no\r\ni\r\nq\r\nm\r\nk\r\nn\r\nd\r\nl\r\np\r\nc\r\nw\r\nu\r\nz\r\nc\r\nk\r\ng\r\ny\r\nj\r\ny\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\ne\r\ne\r\ne\r\ne\r\n', 'output': ['aaaa\r\n']}, {'input': '1 1\r\na\r\ne\r\ne\r\ne\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\ne\r\na\r\ne\r\ne\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\na\r\na\r\ne\r\ne\r\n', 'output': ['aabb\r\n']}, {'input': '1 1\r\ne\r\ne\r\na\r\ne\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\na\r\ne\r\na\r\ne\r\n', 'output': ['abab\r\n']}, {'input': '1 1\r\ne\r\na\r\na\r\ne\r\n', 'output': ['abba\r\n']}, {'input': '1 1\r\na\r\na\r\na\r\ne\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\ne\r\ne\r\ne\r\na\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\na\r\ne\r\ne\r\na\r\n', 'output': ['abba\r\n']}, {'input': '1 1\r\ne\r\na\r\ne\r\na\r\n', 'output': ['abab\r\n']}, {'input': '1 1\r\na\r\na\r\ne\r\na\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\ne\r\ne\r\na\r\na\r\n', 'output': ['aabb\r\n']}, {'input': '1 1\r\na\r\ne\r\na\r\na\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\ne\r\na\r\na\r\na\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\na\r\na\r\na\r\na\r\n', 'output': ['aaaa\r\n']}, {'input': '1 2\r\neraub\r\nbee\r\naab\r\nttbee\r\n', 'output': ['NO\r\n']}, {'input': '10 1\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\ny\r\n', 'output': ['NO\r\n']}, {'input': '1 2\r\neeereaatktb\r\nbee\r\niaattb\r\nottbee\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\nab\r\nac\r\nad\r\naf\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\nar\r\nat\r\nay\r\naw\r\n', 'output': ['NO\r\n']}, {'input': '2 1\r\na\r\ne\r\na\r\ne\r\na\r\na\r\na\r\na\r\n', 'output': ['abab\r\n']}, {'input': '1 1\r\na\r\ne\r\na\r\ni\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\na\r\ne\r\na\r\ne\r\n', 'output': ['abab\r\n']}, {'input': '1 1\r\nabbbbbbbbbbbbbbbbcbbbbbbbbbbbbbbbb\r\nabbbbbbbbbbbbbbbbfbbbbbbbbbbbbbbbb\r\nabbbbbbbbbbbbbbbbxbbbbbbbbbbbbbbbb\r\nabbbbbbbbbbbbbbbbdbbbbbbbbbbbbbbbb\r\n', 'output': ['NO\r\n']}, {'input': '2 1\r\na\r\ne\r\ne\r\na\r\na\r\na\r\na\r\na\r\n', 'output': ['abba\r\n']}, {'input': '1 1\r\nbug\r\nsuy\r\nluh\r\ngut\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\nam\r\nat\r\nan\r\nag\r\n', 'output': ['NO\r\n']}, {'input': '2 1\r\na\r\na\r\ne\r\ne\r\na\r\na\r\na\r\na\r\n', 'output': ['aabb\r\n']}, {'input': '1 4\r\naieoabcd\r\naeioabcd\r\naoeiabcd\r\naoieabcd\r\n', 'output': ['NO\r\n']}, {'input': '1 2\r\naec\r\naed\r\naek\r\naem\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\nar\r\nab\r\nak\r\naz\r\n', 'output': ['NO\r\n']}, {'input': '2 1\r\na\r\na\r\na\r\na\r\na\r\nb\r\nb\r\nb\r\n', 'output': ['NO\r\n']}]


#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <string.h>
using namespace std;

long long N, M;

void init()
{
	cin >> N >> M;
}

void york()
{
	long long ans = 0;
	for (long long b = 1; b <= N; ++b)
		ans += min(b * b, M) * 2;

	//cout << ans << endl;
	// remove duplicated integer root
	// integer root's range
	for (long long r = -2 * N; r <= 2 * N; ++r)
	{
		if (r == 0) continue;
		int moder = ((r % 2) + 2) % 2;

		long long xmin1 = (-2 * N - r);
		long long xmax1= -2 - r;
		long long xmin2;
		long long xmax2;
		if (r > 0)
		{
			xmin2 = 1 / M;
			xmax2 = M / r;
		}
		else
		{
			xmin2 = M / r;
			xmax2 = -1;
		}

		//cout << xmin1 << " " << xmax1 << endl;

		long long xmin = max(xmin1, xmin2);
		long long xmax = min(xmax1, xmax2);
		int xminmoder = ((xmin % 2) + 2) % 2;

		long long app = xmax - xmin + 1;
		if (xminmoder == moder) app++;
		app /= 2;
		if (xmin <= r && r <= xmax) app++;

		//cout << moder << " " << xminmoder << endl;
		//cout << "root = " << r << ", " << xmin << " " << xmax << " app = " << app << endl;

		if (app > 1) ans -= (app - 1);
	}
	cout << ans << endl;
}

int main()
{
	init();
	york();

	return 0;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
typedef double mat[484][484];
bool adj[23][23];
int n,m,a,b,deg[23];
double p[23];
mat g;
int uid[23][23];
int N;
bool f[484];
int main()
{
	scanf("%d%d%d%d",&n,&m,&a,&b);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		adj[u][v]=adj[v][u]=1;
		deg[u]++,deg[v]++;
	}
	for(int i=1;i<=n;i++)scanf("%lf",p+i);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)uid[i][j]=N++;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			int x=uid[i][j];
			if(i==j)g[x][x]=1;
			else
			{
				g[x][x]=p[i]*p[j];
				double pi=(1-p[i])/deg[i],pj=(1-p[j])/deg[j];
				for(int a=1;a<=n;a++)if(adj[i][a])
				{
					g[x][uid[a][j]]=pi*p[j];
					for(int b=1;b<=n;b++)if(adj[j][b])
						g[x][uid[a][b]]=pi*pj,g[x][uid[i][b]]=p[i]*pj;
				}
			}
		}
	for(int i=0;i<N;i++)g[i][i]-=1;
	for(int i=1;i<=n;i++)f[uid[i][i]]=1;
	for(int i=0;i<N;i++)if(!f[i])
	{
		int t=-1;
		if(t==-1)for(int j=i;j<N;j++)if(g[j][i]){t=j;break;}
		f[i]=0;
		for(int j=0;j<N;j++)swap(g[i][j],g[t][j]);
		for(int j=0;j<N;j++)if(i!=j&&g[j][i])
		{
			double v=g[j][i]/g[i][i];
			for(int k=0;k<N;k++)g[j][k]-=v*g[i][k];
		}
	}
	int A=uid[a][b];
	for(int i=1;i<=n;i++)
	{
		int x=uid[i][i];
		printf("%.10lf\n",a!=b?-g[A][x]/g[A][A]:(i==a?1.0:0.0));
	}
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<cstring>
using namespace std;
const int N = 1010;
int w[N][N], temp[N];
long double f[N][N], g[N][N];
void swap(int &a, int &b)
{
     int temp = a;
     a = b;
     b = temp;
}

void sort1(int d, int l, int r)
{
     int i = l, j = r, mid = w[d][(l + r) / 2];
     while (i <= j)
     {
           while (w[d][i] > mid) i++;
           while (w[d][j] < mid) j--;
           if (i <= j)
           {
                 swap(w[d][i], w[d][j]);
                 i++; j--;
           }
     }
     if (i < r) sort1(d, i, r);
     if (l < j) sort1(d, l, j);
}

void sort2(int l, int r)
{
     int i = l, j = r, mid = temp[(l + r) / 2];
     while (i <= j)
     {
           while (temp[i] > mid) i++;
           while (temp[j] < mid) j--;
           if (i <= j)
           {
                 swap(temp[i], temp[j]);
                 i++; j--;
           }
     }
     if (i < r) sort2(i, r);
     if (l < j) sort2(l, j);
}

long double p(int n, int m)
{
       long double temp = 1;
       for (int i = 1; i <= m; i++)
       temp = temp * i / (n + 1 - i);
       return(temp);
}

int main()
{
    int n, m, sum = 0, i, j, limit, s = 0, k;
    double tmp;
    scanf("%d%d", &n, &m);
    for (i = 1; i <= m; i++)
    {
        scanf("%d", &w[i][0]);
        for (j = 1; j <= w[i][0]; j++)
        {
            scanf("%d", &w[i][j]);
            temp[++sum] = w[i][j];
        }
        sort1(i, 1, w[i][0]);
    }
    sort2(1, sum);
    limit = temp[n];
    i = n;
    while (temp[i] == limit && i > 0)
    {
          i--;
          s++;
    }
    memset(f, 0, sizeof(f));
    memset(g, 0, sizeof(g));
    f[0][0] = 1.0;
    g[0][0] = 1;
    for (i = 1; i <= m; i++)
    {
        k = 0;
        while (w[i][k + 1] >= limit && k < w[i][0]) k++;
        if (w[i][k] != limit)
        {
            tmp = p(w[i][0], k);
            for (j = 0; j <= s; j++)
            if (g[i - 1][j] != 0)
            {
                f[i][j] += f[i - 1][j] * tmp;
                g[i][j] += g[i - 1][j];
            }
        }
        else
        {
            tmp = p(w[i][0], k);
            for (j = 1; j <= s; j++)
            if (g[i - 1][j - 1] != 0)
            {
                f[i][j] += f[i - 1][j - 1] * tmp;
                g[i][j] += g[i - 1][j - 1];
            }
            tmp = p(w[i][0], k - 1);
            for (j = 0; j <= s; j++)
            if (g[i - 1][j] != 0)
            {
                f[i][j] += f[i - 1][j] * tmp;
                g[i][j] += g[i - 1][j];
            }
        }
    }
    double ans = double(f[m][s] / g[m][s]);
    printf("%.9f\n", ans);
    return(0);
}


#include<bits/stdc++.h>

using namespace std;
using lint = long long int;

const int MAX_N = 2e5;
const int MAX_M =  3001;
const lint MOD = 998244353;

lint dp1[MAX_M][MAX_M];
lint dp2[MAX_M][MAX_M];
int state[MAX_N];
lint wi[MAX_N];
lint SA, SB;
unordered_map<lint, lint> invdp;

lint pow(lint x, lint N) {
	lint ret = 1;

	while (N) {
		if (N & 1)
			(ret *= x) %= MOD;
		(x *= x) %= MOD;
		N >>= 1;
	}
	return ret;
}

lint inv(lint x) {
	if (invdp[x] != 0)
		return invdp[x];
	return invdp[x] = pow(x, MOD-2);
}

lint solve1(int i, int j, int M) {
	if (dp1[i][j] != -1)
		return dp1[i][j];

	lint &ret = dp1[i][j];
	ret = 0;

	if (i+j == M)
		return ret = 1;

	lint ri = SA + i, rj = SB - j;
	(ret += solve1(i+1, j, M) * (ri + 1) % MOD * inv(ri+rj) % MOD) %= MOD;
	if (SB-j-1 >= 0)
		(ret += solve1(i, j+1, M) * rj % MOD * inv(ri+rj) % MOD) %= MOD;

	return ret;
}

lint solve2(int i, int j, int M) {
	if (dp2[i][j] != -1)
		return dp2[i][j];

	lint &ret = dp2[i][j];
	ret = 0;

	if (i+j == M)
		return ret = 1;

	lint ri = SA + i, rj = SB - j;

	if (rj-1 >= 0)
		(ret += solve2(i, j+1, M) * (rj - 1) % MOD * inv(ri+rj) % MOD) %= MOD;
	(ret += solve2(i+1, j, M) * ri % MOD * inv(ri+rj) % MOD) %= MOD;

	return ret;
}

int main(void) {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	memset(dp1, -1, sizeof dp1);
	memset(dp2, -1, sizeof dp2);

	int N, M;	cin >> N >> M;

	for (int i = 0; i < N; i ++)
		cin >> state[i];

	for (int i = 0; i < N; i ++) {
		cin >> wi[i];

		(state[i]?SA:SB) += wi[i];
	}

	for (int i = 0; i < N; i ++)
		cout << (wi[i]*(state[i]?solve1(0, 0, M):solve2(0, 0, M)))%MOD << '\n';
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back

#define eb emplace_back

#define f first

#define s second

#define deb(a) cerr << #a << " = " << a << "\n";

#define all(x) (x).begin(), (x).end()

#define file() { ifstream cin("input.txt"); ofstream cout("output.txt"); }

#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))

#define y1 y1212312

#define int long long

typedef long long ll;

typedef long double ld;

typedef pair <int, int> pii;

const ll INF = 2e18;

const ll mod = 1e9 + 7;

const int inf = 1e9;

const ld EPS = 1e-12;

const ld Pi = acosl(-1);

const int P = 31;

const int dx[2] = {0, 1};

const int dy[2] = {1, 0};

int qqq = 1;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int x1, y1, x2, y2, x3, y3;

void solve() {

    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

    int leng = x3 * x3 + y3 * y3;

    for (int i = 0; i < 4; i++) {

        int x = x2 - x1;

        int y = y2 - y1;

        int dp = x * x3 + y * y3;

        int cp = x * y3 - y * x3;

        if (x == 0 && y == 0) {

            cout << "YES\n";

            return;

        }

        if (leng && dp % leng == 0 && cp % leng == 0) {

            cout << "YES\n";

            return;

        }

        x1 = -x1;

        swap(x1, y1);

    }

    cout << "NO\n";

}

signed main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0); cout.tie(0);

    clock_t tStart = clock();

    //cin >> qqq;

    while (qqq--) {

        solve();

    }

    cerr << "Runtime is:" << (long double) (clock() - tStart) / CLOCKS_PER_SEC << '\n';

    return 0;

}


#pragma GCC target("avx")//AVX指令集(不懂的去问度娘)
#pragma GCC optimize(2)//吸氧气(O2)
#pragma GCC optimize(3)//吸臭氧(O3)
#pragma GCC optimize("Ofast")//吸更高质量的氧(优化到破坏标准合规性的点)，
#include <bits/stdc++.h>
#define int long long
#define double long double
using std::cin;
using std::cout;

const int N = 200007;
int n, a[N], s[N];

double f(int len, int mid) {
    double average = s[mid] - s[mid - len - 1] + s[n] - s[n - len];
    average /= (len << 1 | 1);
    return average - a[mid];
}

signed main() {
	std::ios::sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; ++ i) cin >> a[i];
	if (n <= 2) {
		cout << n << '\n';
		for (int i = 1; i <= n; ++ i) cout << a[i] << ' ';
		cout << '\n';
		return 0;
	}
	std::sort(a + 1, a + 1 + n);
	int pos = 0, max = 0;
	double ans = 0;
	for (int i = 1; i <= n; ++ i) s[i] = a[i] + s[i - 1];
//	cout << f(1, 2) << '\n';
	for (int i = 1; i <= n; ++ i) {
		int l = 0, r = std::min(i - 1, n - i);
		while (l + 2 < r) {
        	int midl = l + (r - l + 1) / 3, midr = r - (r - l + 1) / 3;
			if (f(midl, i) < f(midr, i)) l = midl;
			else r = midr;
		}
		double res = 0, pos_ = 0, max_ = 0;
		for (int j = l; j <= r; ++ j) {
			if (f(j, i) > res) {
				res = f(j, i);
				max_ = j;
			}
		}
		if (res > ans) {
			ans = res;
			pos = i;
			max = max_;
		}
//		cout << ans << '\n';
	}
	if (ans == 0) {
		cout << 1 << '\n';
		cout << a[1] << '\n';
	} else {
		cout << 2 * max + 1 << '\n';
		for (int i = pos - max; i <= pos; ++ i) cout << a[i] << ' ';
		for (int i = n - max + 1; i <= n; ++ i) cout << a[i] << ' ';
	}
	return 0;
}


#include <bits/stdc++.h>

#define int int64_t

using namespace std;

int d(int x) {
    return 1 + (x-1)%9;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> F(10,0);
    int n;
    cin >> n;
    int answer = 0;
    for (int i = 1; i<= n; i++) {
        F[d(i)]++;
    }for (int i = 1; i<= 9;i++) {
        for (int j = 1; j<= 9; j++) {
            answer += F[i] * F[j] * F[d(i*j)];
        }
    }for (int i = 1; i<= n; i++) {
        answer-= n/i;
    }cout << answer << "\n";
}/*1688643701.7248943*/


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author caoash
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BArrayKColoring solver = new BArrayKColoring();
        solver.solve(1, in, out);
        out.close();
    }

    static class BArrayKColoring {
        public void solve(int testNumber, FastScanner br, PrintWriter pw) {
            int n = br.nextInt();
            int k = br.nextInt();
            Pair[] data = new Pair[n];
            for (int i = 0; i < data.length; i++) {
                data[i] = new Pair(br.nextInt(), i);
            }
            Arrays.sort(data);
            int[] fin = new int[n];
            int curr = 1;
            for (int i = 0; i < n; i++) {
                fin[i] = curr++;
                if (curr == k + 1) {
                    curr = 1;
                }
            }
            int[] ret = new int[n];
            boolean[][] used = new boolean[5001][5001];
            for (int i = 0; i < n; i++) {
                ret[data[i].s] = fin[i];
            }
//        for(int i = 0; i < n; i++){
//            pw.print(ret[i] + " ");
//        }
//        pw.println();
            for (int i = 0; i < n; i++) {
                if (used[data[i].f][fin[i]]) {
                    pw.println("NO");
                    pw.close();
                    return;
                } else {
                    used[data[i].f][fin[i]] = true;
                }
            }
            pw.println("YES");
            for (int i = 0; i < n; i++) {
                pw.print(ret[i] + " ");
            }
            pw.close();
        }

    }

    static class Pair implements Comparable<Pair> {
        public int f;
        public int s;

        public Pair(int f, int s) {
            this.f = f;
            this.s = s;
        }

        public int compareTo(Pair p) {
            return this.f == p.f ? this.s - p.s : this.f - p.f;
        }

        public String toString() {
            return "(" + f + "," + s + ")";
        }

    }

    static class FastScanner {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastScanner.SpaceCharFilter filter;

        public FastScanner(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scn=new Scanner(System.in);
        int k=scn.nextInt();
        int l=scn.nextInt();
        int m=scn.nextInt();
        int n=scn.nextInt();
        int d=scn.nextInt();
        int arr[]=new int[d+1];
        for(int i=k;i<arr.length;i+=k) {
            arr[i]=1;
        }
        for(int i=l;i<arr.length;i+=l) {
            arr[i]=1;
        }
        for(int i=m;i<arr.length;i+=m) {
            arr[i]=1;
        }
        for(int i=n;i<arr.length;i+=n) {
            arr[i]=1;
        }
        int ans=0;
        for(int i=1;i<arr.length;i++) {
            if(arr[i]==1)
                ans++;
        }
        System.out.println(ans);
    }
}


import java.util.HashMap;
import java.util.Scanner;

public class que2 {

	public static void main(String[] args) {
    Scanner scn=new Scanner(System.in);
    int test=scn.nextInt();
    for(int t=1;t<=test;t++){
    	int n=scn.nextInt();
    	int d=scn.nextInt();
    	int k=scn.nextInt();
    HashMap<Integer,Integer> map=new HashMap<>();
    int []arr=new int[n];
    for(int i=0;i<n;i++){
    	arr[i]=scn.nextInt();

    }

    for(int i=0;i<k;i++){
    	map.put(arr[i], map.getOrDefault(arr[i], 0)+1);
    }
    int min=map.size();
    for(int i=k;i<n;i++){
   int fr=map.get(arr[i-k]);
   if(fr==1){
	   map.remove(arr[i-k]);
   }else{
	   map.put(arr[i-k], map.get(arr[i-k])-1);
   }
   map.put(arr[i], map.getOrDefault(arr[i], 0)+1);
   min=Math.min(min, map.size());
    }
    System.out.println(min);
    }

	}

}


import java.lang.*;
import java.util.*;

public class Luckysubstring {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String input = in.nextLine();
        int count4 = 0;
        int count7 = 0;
        in.close();
        if (input.contains("4") || input.contains("7")) {
            for (int i = 0; i < input.length(); i++) {
                if (input.charAt(i) == '4') {
                    count4++;
                } else if (input.charAt(i) == '7') {
                    count7++;
                }
            }
            if (count4 >= count7) {
                System.out.println(4);
            } else {
                System.out.println(7);
            }
        } else {
            System.out.println(-1);
        }

    }
}


import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String[] first = in.nextLine().split(" ");
        int n = Integer.valueOf(first[0]);
        int b = Integer.valueOf(first[1]);

        String[] second = in.nextLine().split(" ");
        int[] c = new int[second.length];
        int sum = 0;
        for (int i = 0; i < c.length; i++) {
        	c[i] = Integer.valueOf(second[i]);
        	sum += c[i];
        }

        double q = (double)(b + sum) / n;
        String result = "";
        for (int i = 0; i < c.length; i++) {
        	if (c[i] > q) {
        		System.out.println(-1);
        		return;
        	}
        	result += String.format(new Locale("Russian"), "%.6f", (q - c[i])) + "\n";
        }

        System.out.println(result);
    }
}


import java.util.*;
import java.io.*;

public class Main {
 	public static void main(String[] args){
		FastScanner scanner = new FastScanner();
		int n = scanner.nextInt();
		int x1 = scanner.nextInt();
		int y1 = scanner.nextInt();
		int x2 = scanner.nextInt();
		int y2 = scanner.nextInt();
		int min = 10000;
		if((x1 == 0 && x2 == n) || (x1 == n && x2 == 0)){
			min = Math.min(min, y1+y2+n);
			min = Math.min(min, 3*n-y1-y2);
		}else if((y1 == 0 && y2 == n) || (y1 == n && y2 == 0)){
			min = Math.min(min, n+x1+x2);
			min = Math.min(min, 3*n-x1-x2);
		}else if(y1 == 0 && x2 == n){
			min = Math.min(min, n-x1+y2);
		}else if(y2 == 0 && x1 == n){
			min = Math.min(min,n-x2+y1);
		}else if(x1 == 0 && y2 == 0){
			min = Math.min(min,x2+y1);
		}else if(x2 == 0 && y1 == 0){
			min = Math.min(min,y2+x1);
		}else if(x1 == 0 && y2 == n){
			min = Math.min(min,n-y1+x2);
		}else if(x2 == 0 && y1 == n){
			min = Math.min(min,n-y2+x1);
		}else if(x1 == n && y2 == n){
			min = Math.min(min, n-y1+n-x2);
		}else if(x2 == n && y1 == n){
			min = Math.min(min, n-x1+n-y2);
		}else if((x1 == 0 && x2 == 0) || (x1 == n && x2 == n)){
			min = Math.min(min,Math.abs(y1-y2));
		}else if((y1 == 0 && y2 == 0) || (y1 == n && y2 == n)){
			min = Math.min(min,Math.abs(x1-x2));
		}
		System.out.println(min);
	}

	private static class FastScanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
				if (ptr < buflen) {
						return true;
				}else{
						ptr = 0;
						try {
								buflen = in.read(buffer);
						} catch (IOException e) {
								e.printStackTrace();
						}
						if (buflen <= 0) {
								return false;
						}
				}
				return true;
		}
		private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
		private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
		public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
		public String next() {
				if (!hasNext()) throw new NoSuchElementException();
				StringBuilder sb = new StringBuilder();
				int b = readByte();
				while(isPrintableChar(b)) {
						sb.appendCodePoint(b);
						b = readByte();
				}
				return sb.toString();
		}
		public long nextLong() {
				if (!hasNext()) throw new NoSuchElementException();
				long n = 0;
				boolean minus = false;
				int b = readByte();
				if (b == '-') {
						minus = true;
						b = readByte();
				}
				if (b < '0' || '9' < b) {
						throw new NumberFormatException();
				}
				while(true){
						if ('0' <= b && b <= '9') {
								n *= 10;
								n += b - '0';
						}else if(b == -1 || !isPrintableChar(b)){
								return minus ? -n : n;
						}else{
								throw new NumberFormatException();
						}
						b = readByte();
				}
		}
		public int nextInt() {
				long nl = nextLong();
				if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
				return (int) nl;
		}
		public double nextDouble() { return Double.parseDouble(next());}
	}
}


import java.util.HashSet;
import java.util.Scanner;

public class Nafis {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int sz = str.length();
        HashSet<Character> freq = new HashSet<>();
        for (int i = 0; i <= sz / 2; i++) {
            if (str.charAt(i) == str.charAt(sz - i - 1)) {
                freq.add(str.charAt(i));
                continue;
            } else {
                System.out.println(sz);
                return;
            }
        }

        System.out.println(freq.size() == 1 ? 0 : sz - 1);

    }
}

[{'input': 'mew\r\n', 'output': ['3']}, {'input': 'wuffuw\r\n', 'output': ['5']}, {'input': 'qqqqqqqq\r\n', 'output': ['0']}, {'input': 'ijvji\r\n', 'output': ['4']}, {'input': 'iiiiiii\r\n', 'output': ['0']}, {'input': 'wobervhvvkihcuyjtmqhaaigvvgiaahqmtjyuchikvvhvrebow\r\n', 'output': ['49']}, {'input': 'wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\r\n', 'output': ['0']}, {'input': 'wobervhvvkihcuyjtmqhaaigvahheoqleromusrartldojsjvy\r\n', 'output': ['50']}, {'input': 'ijvxljt\r\n', 'output': ['7']}, {'input': 'fyhcncnchyf\r\n', 'output': ['10']}, {'input': 'ffffffffffff\r\n', 'output': ['0']}, {'input': 'fyhcncfsepqj\r\n', 'output': ['12']}, {'input': 'ybejrrlbcinttnicblrrjeby\r\n', 'output': ['23']}, {'input': 'yyyyyyyyyyyyyyyyyyyyyyyyy\r\n', 'output': ['0']}, {'input': 'ybejrrlbcintahovgjddrqatv\r\n', 'output': ['25']}, {'input': 'oftmhcmclgyqaojljoaqyglcmchmtfo\r\n', 'output': ['30']}, {'input': 'oooooooooooooooooooooooooooooooo\r\n', 'output': ['0']}, {'input': 'oftmhcmclgyqaojllbotztajglsmcilv\r\n', 'output': ['32']}, {'input': 'gxandbtgpbknxvnkjaajknvxnkbpgtbdnaxg\r\n', 'output': ['35']}, {'input': 'gggggggggggggggggggggggggggggggggggg\r\n', 'output': ['0']}, {'input': 'gxandbtgpbknxvnkjaygommzqitqzjfalfkk\r\n', 'output': ['36']}, {'input': 'fcliblymyqckxvieotjooojtoeivxkcqymylbilcf\r\n', 'output': ['40']}, {'input': 'fffffffffffffffffffffffffffffffffffffffffff\r\n', 'output': ['0']}, {'input': 'fcliblymyqckxvieotjootiqwtyznhhvuhbaixwqnsy\r\n', 'output': ['43']}, {'input': 'rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr\r\n', 'output': ['0']}, {'input': 'rajccqwqnqmshmerpvjyfepxwpxyldzpzhctqjnstxyfmlhiy\r\n', 'output': ['49']}, {'input': 'a\r\n', 'output': ['0']}, {'input': 'abca\r\n', 'output': ['4']}, {'input': 'aaaaabaaaaa\r\n', 'output': ['10']}, {'input': 'aba\r\n', 'output': ['2']}, {'input': 'asaa\r\n', 'output': ['4']}, {'input': 'aabaa\r\n', 'output': ['4']}, {'input': 'aabbaa\r\n', 'output': ['5']}, {'input': 'abcdaaa\r\n', 'output': ['7']}, {'input': 'aaholaa\r\n', 'output': ['7']}, {'input': 'abcdefghijka\r\n', 'output': ['12']}, {'input': 'aaadcba\r\n', 'output': ['7']}, {'input': 'aaaabaaaa\r\n', 'output': ['8']}, {'input': 'abaa\r\n', 'output': ['4']}, {'input': 'abcbaa\r\n', 'output': ['6']}, {'input': 'ab\r\n', 'output': ['2']}, {'input': 'l\r\n', 'output': ['0']}, {'input': 'aaaabcaaaa\r\n', 'output': ['10']}, {'input': 'abbaaaaaabba\r\n', 'output': ['11']}, {'input': 'abaaa\r\n', 'output': ['5']}, {'input': 'baa\r\n', 'output': ['3']}, {'input': 'aaaaaaabbba\r\n', 'output': ['11']}, {'input': 'ccbcc\r\n', 'output': ['4']}, {'input': 'bbbaaab\r\n', 'output': ['7']}, {'input': 'abaaaaaaaa\r\n', 'output': ['10']}, {'input': 'abaaba\r\n', 'output': ['5']}, {'input': 'aabsdfaaaa\r\n', 'output': ['10']}, {'input': 'aaaba\r\n', 'output': ['5']}, {'input': 'aaabaaa\r\n', 'output': ['6']}, {'input': 'baaabbb\r\n', 'output': ['7']}, {'input': 'ccbbabbcc\r\n', 'output': ['8']}, {'input': 'cabc\r\n', 'output': ['4']}, {'input': 'aabcd\r\n', 'output': ['5']}, {'input': 'abcdea\r\n', 'output': ['6']}, {'input': 'bbabb\r\n', 'output': ['4']}, {'input': 'aaaaabababaaaaa\r\n', 'output': ['14']}, {'input': 'bbabbb\r\n', 'output': ['6']}, {'input': 'aababd\r\n', 'output': ['6']}, {'input': 'abaaaa\r\n', 'output': ['6']}, {'input': 'aaaaaaaabbba\r\n', 'output': ['12']}, {'input': 'aabca\r\n', 'output': ['5']}, {'input': 'aaabccbaaa\r\n', 'output': ['9']}, {'input': 'aaaaaaaaaaaaaaaaaaaab\r\n', 'output': ['21']}, {'input': 'babb\r\n', 'output': ['4']}, {'input': 'abcaa\r\n', 'output': ['5']}, {'input': 'qwqq\r\n', 'output': ['4']}, {'input': 'aaaaaaaaaaabbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaa\r\n', 'output': ['48']}, {'input': 'aaab\r\n', 'output': ['4']}, {'input': 'aaaaaabaaaaa\r\n', 'output': ['12']}, {'input': 'wwuww\r\n', 'output': ['4']}, {'input': 'aaaaabcbaaaaa\r\n', 'output': ['12']}, {'input': 'aaabbbaaa\r\n', 'output': ['8']}, {'input': 'aabcbaa\r\n', 'output': ['6']}, {'input': 'abccdefccba\r\n', 'output': ['11']}, {'input': 'aabbcbbaa\r\n', 'output': ['8']}, {'input': 'aaaabbaaaa\r\n', 'output': ['9']}, {'input': 'aabcda\r\n', 'output': ['6']}, {'input': 'abbca\r\n', 'output': ['5']}, {'input': 'aaaaaabbaaa\r\n', 'output': ['11']}, {'input': 'sssssspssssss\r\n', 'output': ['12']}, {'input': 'sdnmsdcs\r\n', 'output': ['8']}, {'input': 'aaabbbccbbbaaa\r\n', 'output': ['13']}, {'input': 'cbdbdc\r\n', 'output': ['6']}, {'input': 'abb\r\n', 'output': ['3']}, {'input': 'abcdefaaaa\r\n', 'output': ['10']}, {'input': 'abbbaaa\r\n', 'output': ['7']}, {'input': 'v\r\n', 'output': ['0']}, {'input': 'abccbba\r\n', 'output': ['7']}, {'input': 'axyza\r\n', 'output': ['5']}, {'input': 'abcdefgaaaa\r\n', 'output': ['11']}, {'input': 'aaabcdaaa\r\n', 'output': ['9']}, {'input': 'aaaacaaaa\r\n', 'output': ['8']}, {'input': 'aaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaa\r\n', 'output': ['42']}, {'input': 'abbbaa\r\n', 'output': ['6']}, {'input': 'abcdee\r\n', 'output': ['6']}, {'input': 'oom\r\n', 'output': ['3']}, {'input': 'aabcaa\r\n', 'output': ['6']}, {'input': 'abba\r\n', 'output': ['3']}, {'input': 'aaca\r\n', 'output': ['4']}, {'input': 'aacbca\r\n', 'output': ['6']}, {'input': 'ababa\r\n', 'output': ['4']}, {'input': 'abcda\r\n', 'output': ['5']}, {'input': 'cccaaccc\r\n', 'output': ['7']}, {'input': 'aaabcda\r\n', 'output': ['7']}, {'input': 'aa\r\n', 'output': ['0']}, {'input': 'aabaaaa\r\n', 'output': ['7']}, {'input': 'abbaaaa\r\n', 'output': ['7']}, {'input': 'aaabcbaaa\r\n', 'output': ['8']}, {'input': 'aabba\r\n', 'output': ['5']}, {'input': 'xyxx\r\n', 'output': ['4']}, {'input': 'aaaaaaaaaaaabc\r\n', 'output': ['14']}, {'input': 'bbaaaabb\r\n', 'output': ['7']}, {'input': 'aaabaa\r\n', 'output': ['6']}, {'input': 'sssssabsssss\r\n', 'output': ['12']}, {'input': 'bbbaaaabbb\r\n', 'output': ['9']}, {'input': 'abbbbaaaa\r\n', 'output': ['9']}, {'input': 'wwufuww\r\n', 'output': ['6']}, {'input': 'oowoo\r\n', 'output': ['4']}, {'input': 'cccaccc\r\n', 'output': ['6']}, {'input': 'aaa\r\n', 'output': ['0']}, {'input': 'bbbcc\r\n', 'output': ['5']}, {'input': 'abcdef\r\n', 'output': ['6']}, {'input': 'abbba\r\n', 'output': ['4']}, {'input': 'aab\r\n', 'output': ['3']}, {'input': 'aaba\r\n', 'output': ['4']}, {'input': 'azbyaaa\r\n', 'output': ['7']}, {'input': 'oooooiooooo\r\n', 'output': ['10']}, {'input': 'aabbbbbaaaaaa\r\n', 'output': ['13']}]


import java.lang.*;
import java.util.*;
import java.io.*;
public class test
{

  Scanner sc=new Scanner(System.in);
  PrintWriter pr=new PrintWriter(System.out,true);
  public static void main(String... args)
  {
       test c=new test();
       c.prop();
  }
  public void prop()
  {
    int n,count=1 ;
    Stack<Integer> s=new Stack<Integer>();
     s.push(0);
      n=sc.nextInt();
        for (int i=1; ;++i) {
            if(n%2==0)
            {
              ++count ;
              n=n/2 ;
            }else
              {
                s.push(count);
                n=n-1 ;
              }
            if(n==0)
             break ;
        }
       for (; ; ) {
          n=s.pop();
            if(n==0)
              break ;
            else
              pr.print(n+" ");
       }
      pr.println("");

  }
}


import java.util.Scanner;

public class CF2 {
	public static void main  (String [] args ) {
		Scanner mos = new Scanner  ( System.in ) ;
		int a = mos.nextInt ()  ;
		int c = 0 ;
		int temp ;
		int [] b = new int [a] ;
		for ( int i = 0 ; i < b.length ; i ++ )
			b [i] = mos.nextInt();
		for ( int i = 0 ; i < b.length ; i++ )
			for ( int j = 0  ; j < i ; j ++ ){
				if ( b [ i ] < b [ j ]){
					temp = b[i] ;
					b[i] = b[j] ;
					b[j] = temp ;
				}
			}

		for ( int i = 1 ; i < b.length ; i++ ){
			for ( int j = 0 ; j < i ; j ++ )
				if ( b[i] == b[j]){
					c ++ ;
				}
			if ( c == 0 ){
				System.out.println( b[i] );
				c++ ;
				break ;

			}
			c = 0 ;

		}
		if ( c == 0 || b.length <= 1 )
			System.out.println("NO");
	}

}


import java.util.Scanner;

public class Letter {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String check = in.nextLine();
		for(int i=0;i<check.length();i++){
			if(check.charAt(i)==' ')
				continue;
			if((!s.contains(check.charAt(i)+""))|| (count(s,check.charAt(i))<count(check,check.charAt(i)))){
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
	}
	static int count(String s,char ch){
		int c=0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)==ch)
				c++;
		}
		return c;
	}
}

[{'input': 'Instead of dogging Your footsteps it disappears but you dont notice anything\r\nwhere is your dog\r\n', 'output': ['NO\r\n']}, {'input': 'Instead of dogging Your footsteps it disappears but you dont notice anything\r\nYour dog is upstears\r\n', 'output': ['YES\r\n']}, {'input': 'Instead of dogging your footsteps it disappears but you dont notice anything\r\nYour dog is upstears\r\n', 'output': ['NO\r\n']}, {'input': 'abcdefg hijk\r\nk j i h g f e d c b a\r\n', 'output': ['YES\r\n']}, {'input': 'HpOKgo\r\neAtAVB\r\n', 'output': ['NO\r\n']}, {'input': 'GRZGc\r\nLPzD\r\n', 'output': ['NO\r\n']}, {'input': 'GtPXu\r\nd\r\n', 'output': ['NO\r\n']}, {'input': 'FVF\r\nr \r\n', 'output': ['NO\r\n']}, {'input': 'HpOKgo\r\nogK\r\n', 'output': ['YES\r\n']}, {'input': 'GRZGc\r\nZG\r\n', 'output': ['YES\r\n']}, {'input': 'HpOKgoueAtAVBdGffvQheJDejNDHhhwyKJisugiRAH OseK yUwqPPNuThUxTfthqIUeb wS jChGOdFDarNrKRT  MlwKecxWNoKEeD BbiHAruE XMlvKYVsJGPP\r\nAHN  XvoaNwV  AVBKwKjr u      U K wKE D K   Jy KiHsR h d W  Js IHyMPK Br iSqe  E fDA   g H\r\n', 'output': ['YES\r\n']}, {'input': 'GRZGcsLPzDrCSXhhNTaibJqVphhjbcPoZhCDUlzAbDnRWjHvxLKtpGiFWiGbfeDxBwCrdJmJGCGv GebAOinUsFrlqKTILOmxrFjSpEoVGoTdSSstJWVgMLKMPettxHASaQZNdOIObcTxtF qTHWBdNIKwj\r\nWqrxze Ji x q aT GllLrRV jMpGiMDTwwS JDsPGpAZKACmsFCOS CD Sj  bCDgKF  jJxa RddtLFAi VGLHH SecObzG q  hPF \r\n', 'output': ['YES\r\n']}, {'input': 'GtPXuwdAxNhODQbjRslDDKciOALJrCifTjDQurQEBeFUUSZWwCZQPdYwZkYbrduMijFjgodAOrKIuUKwSXageZuOWMIhAMexyLRzFuzuXqBDTEaWMzVdbzhxDGSJC SsIYuYILwpiwwcObEHWpFvHeBkWYNitqYrxqgHReHcKnHbtjcWZuaxPBVPb\r\nTQIKyqFaewOkY lZUOOuxEw EwuKcArxRQGFYkvVWIAe SuanPeHuDjquurJu aSxwgOSw jYMwjxItNUUArQjO BIujAhSwttLWp\r\n', 'output': ['YES\r\n']}, {'input': 'FVFSr unvtXbpKWF vPaAgNaoTqklzVqiGYcUcBIcattzBrRuNSnKUtmdGKbjcE\r\nUzrU K  an GFGR        Wc zt iBa     P c    T K v p     V In   b           B   c\r\n', 'output': ['YES\r\n']}, {'input': 'lSwjnYLYtDNIZjxHiTawdh ntSzggZogcIZTuiTMWVgwyloMtEhqkrOxgIcFvwvsboXUPILPIymFAEXnhApewJXJNtFyZ\r\nAoxe  jWZ u  yImg  o AZ FNI w lpj  tNhT g y  ZYcb rc J    w Dlv\r\n', 'output': ['YES\r\n']}, {'input': 'kvlekcdJqODUKdsJlXkRaileTmdGwUHWWgvgUokQxRzzbpFnswvNKiDnjfOFGvFcnaaiRnBGQmqoPxDHepgYasLhzjDgmvaFfVNEcSPVQCJKAbSyTGpXsAjIHr\r\nGjzUllNaGGKXUdYmDFpqFAKIwvTpjmqnyswWRTnxlBnavAGvavxJemrjvRJc\r\n', 'output': ['YES\r\n']}, {'input': 'kWbvhgvvoYOhwXmgTwOSCDXrtFHhqwvMlCvsuuAUXMmWaYXiqHplFZZemhgkTuvsUtIaUxtyYauBIpjdbyYxjZ ZkaBPzwqPfqF kCqGRmXvWuabnQognnkvdNDtRUsSUvSzgBuxCMBWJifbxWegsknp\r\nBsH   bWHJD n Ca T xq  PRCv  tatn Wjy sm  I q s WCjFqdWe  t W XUs  Do  eb Pfh ii  hTbF  O Fll\r\n', 'output': ['YES\r\n']}, {'input': 'OTmLdkMhmDEOMQMiW ZpzEIjyElHFrNCfFQDp SZyoZaEIUIpyCHfwOUqiSkKtFHggrTBGkqfOxkChPztmPrsHoxVwAdrxbZLKxPXHlMnrkgMgiaHFopiFFiUEtKwCjpJtwdwkbJCgA bxeDIscFdmHQJLAMNhWlrZisQrHQpvbALWTwpf jnx\r\nDbZwrQbydCdkJMCrftiwtPFfpMiwwrfIrKidEChKECxQUBVUEfFirbGWiLkFQkdJiFtkrtkbIAEXCEDkwLpK\r\n', 'output': ['YES\r\n']}, {'input': 'NwcGaIeSkOva\r\naIa\r\n', 'output': ['YES\r\n']}, {'input': 'gSrAcVYgAdbdayzbKGhIzLDjyznLRIJH KyvilAaEddmgkBPCNzpmPNeGEbmmpAyHvUSoPvnaORrPUuafpReEGoDOQsAYnUHYfBqhdcopQfxJuGXgKnbdVMQNhJYkyjiJDKlShqBTtnnDQQzEijOMcYRGMgPGVhfIReYennKBLwDTVvcHMIHMgVpJkvzTrezxqS\r\nHJerIVvRyfrPgAQMTI AqGNO mQDfDwQHKgeeYmuRmozKHILvehMPOJNMRtPTAfvKvsoGKi xHEeKqDAYmQJPUXRJbIbHrgVOMGMTdvYiLui\r\n', 'output': ['YES\r\n']}, {'input': 'ReB hksbHqQXxUgpvoNK bFqmNVCEiOyKdKcAJQRkpeohpfuqZabvrLfmpZOMcfyFBJGZwVMxiUPP pbZZtJjxhEwvrAba\r\nJTCpQnIViIGIdQtLnmkVzmcbBZR CoxAdTtWSYpbOglDFifqIVQ vfGKGtLpxpJHiHSWCMeRcrVOXBGBhoEnVhNTPWGTOErNtSvokcGdgZXbgTEtISUyTwaXUEIlJMmutsdCbiyrPZPJyRdOjnSuAGttLy\r\n', 'output': ['NO\r\n']}, {'input': 'hrLzRegCuDGxTrhDgVvM KowwyYuXGzIpcXdSMgeQVfVOtJZdkhNYSegwFWWoPqcZoeapbQnyCtojgkcyezUNHGGIZrhzsKrvvcrtokIdcnqXXkCNKjrOjrnEAKBNxyDdiMVeyLvXxUYMZQRFdlcdlcxzKTeYzBlmpNiwWbNAAhWkMoGpRxkCuyqkzXdKWwGH\r\nJESKDOfnFdxPvUOCkrgSBEPQHJtJHzuNGstRbTCcchRWJvCcveSEAtwtOmZZiW\r\n', 'output': ['NO\r\n']}, {'input': 'yDBxCtUygQwWqONxQCcuAvVCkMGlqgC zvkfEkwqbhMCQxnkwQIUhucCbVUyOBUcXvTNEGriTBwMDMfdsPZgWRgIUDqM\r\neptVnORTTyixxmWIBpSTEwOXqGZllBgSxPenYCDlFwckJlWsoVwWLAIbPOmFqcKcTcoQqahetl KLfVSyaLVebzsGwPSVbtQAeUdZAaJtfxlCEvvaRhLlVvRJhKat IaB awdqcDlrrhTbRxjEbzGwcdmdavkhcjHjzmwbxAgw\r\n', 'output': ['NO\r\n']}, {'input': 'jlMwnnotSdlQMluKWkJwAeCetcqbIEnKeNyLWoKCGONDRBQOjbkGpUvDlmSFUJ bWhohqmmIUWTlDsvelUArAcZJBipMDwUvRfBsYzMdQnPDPAuBaeJmAxVKwUMJrwMDxNtlrtAowVWqWiwFGtmquZAcrpFsLHCrvMSMMlvQUqypAihQWrFMNoaqfs IBg\r\nNzeWQ bafrmDsYlpNHSGTBBgPl WIcuNhyNaNOEFvL\r\n', 'output': ['NO\r\n']}, {'input': 'zyWvXBcUZqGqjHwZHQryBtFliLYnweXAoMKNpLaunaOlzaauWmLtywsEvWPiwxJapocAFRMjrqWJXYqfKEbBKnzLO\r\npsbi bsXpSeJaCkIuPWfSRADXdIClxcDCowwJzGCDTyAl\r\n', 'output': ['NO\r\n']}, {'input': 'kKhuIwRPLCwPFfcnsyCfBdnsraGeOCcLTfXuGjqFSGPSAeDZJSS bXKFanNqWjpFnvRpWxHJspvisDlADJBioxXNbVoXeUedoPcNEpUyEeYxdJXhGzFAmpAiHotSVwbZQsuWjIVhVaEGgqbZHIoDpiEmjTtFylCwCkWWzUOoUfOHxEZvDwNpXhBWamHn\r\nK VpJjGhNbwCRhcfmNGVjewBFpEmPlIKeTuWiukDtEWpjgqciqglkyNfWrBLbGAKvlNWxaUelJmSlSoakSpRzePvJsshOsTYrMPXdxKpaShjyVIXGhRIAdtiGpNwtiRmGTBZhkJqIMdxMHX RMxCMYcWjcjhtCHyFnCvjjezGbkRDRiVxkbh\r\n', 'output': ['NO\r\n']}, {'input': 'AXssNpFKyQmJcBdBdfkhhMUzfqJVgcLBddkwtnFSzSRUCjiDcdtmkzIGkCKSxWUEGhmHmciktJyGMkgCductyHx\r\nI nYhmJfPnvoKUiXYUBIPIcxNYTtvwPUoXERZvY ahlDpQFNMmVZqEBiYqYlHNqcpSCmhFczBlOAhsYFeqMGfqL EJsDNOgwoJfBzqijKOFcYQ\r\n', 'output': ['NO\r\n']}, {'input': 'lkhrzDZmkdbjzYKPNMRkiwCFoZsMzBQMnxxdKKVJezSBjnLjPpUYtabcPTIaDJeDEobbWHdKOdVfMQwDXzDDcSrwVenDEYpMqfiOQ xSsqApWnAMoyhQXCKFzHvvzvUvkWwmwZrvZz\r\nsUzGspYpRFsHRbRgTQuCBgnFgPkisTUfFNwyEEWWRiweWWgjRkVQxgTwxOzdsOwfrGIH O gCXpzvHzfItuEHaihmugEyymSJIogYwX qAwcwIItidfnzZDhZgQHi eRjMAeVkJHceDZuJkmxGowOsmcGYYvk Ajtgi TxwihvjLViNZjvscTWvsaQUelTSivLShhEl\r\n', 'output': ['NO\r\n']}, {'input': 'BRsVjyNhrqRHVwrJzuzRigEhdpbDmaACSPfed\r\nlWqKTjlrqOCUbgBBZdZDGCeQJDXawPnnDkQdZDgwrEQk\r\n', 'output': ['NO\r\n']}, {'input': 'KRmINuyBYPwiTsdlyiNVuylToysJKmOpcLovAtwGPqrgFJQNAYvuAiyQRkeFMECVZvkDEmTauXlyjAaYRnTJXORMZRnTakBaUzSelMilejySDIZjQjzcOIrwXdvDvpeRIkoBgreyFXIyyIZutjiEBtwrmzQtPVUhvvdEtDMbXjBpoPVjGdM EXTAK JbCnw\r\nXZZqlJvzKKtvdNlzFPDTYxidqlsgufVzyEmO FZuLQ vVQsJESNviUCovCK NwwlbxsmPtOJNmAonCqrOZ bZ LVKAsQGmoLnYjeekvEIECFk\r\n', 'output': ['NO\r\n']}]


import java.util.*;

public class Trying
{
    public static void main (String[] args)
    {
        Scanner enter = new Scanner(System.in);
        int n = enter.nextInt(), scores [] = new int [n], pos = 0, max = Integer.MIN_VALUE;
        String handles[] = new String [n];
        for(int i = 0 ; i < n ; i++)
        {
            handles[i] = enter.next();
            scores[i] += (enter.nextInt()*100) - (enter.nextInt()*50)
            + enter.nextInt() + enter.nextInt() + enter.nextInt() + enter.nextInt() + enter.nextInt() ;
            if(scores[i] > max){max = scores[i]; pos = i;}
        }
        System.out.println(handles[pos]);
    }
}


import java.util.*;
import java.io.*;

public class Solution {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

        String str = scan.next();
        int n = str.length();
        int k = scan.nextInt();
        if(k == 1)
        	System.out.println(0);
        else{
	        HashSet<Character> set = new HashSet<Character>();
		    for(int i = 0; i < n; i++)
		    	set.add(str.charAt(i));
		    int res = (k-set.size());
		    if(k > n)
		    	System.out.println("impossible");
		    else if(res >= 0)
		    	System.out.println(res);
		    else
		    	System.out.println(0);
	  	}
		scan.close();
	}
}


import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Task4 {
    static class FastScanner{
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public FastScanner()
        {
            stream = System.in;
        }

        int read()
        {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars){
                curChar = 0;
                try{
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        boolean isSpaceChar(int c)
        {
            return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
        }

        boolean isEndline(int c)
        {
            return c=='\n'||c=='\r'||c==-1;
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String next(){
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do{
                res.appendCodePoint(c);
                c = read();
            }while(!isSpaceChar(c));
            return res.toString();
        }

        String nextLine(){
            int c = read();
            while (isEndline(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do{
                res.appendCodePoint(c);
                c = read();
            }while(!isEndline(c));
            return res.toString();
        }
    }

    public static void main(String[] args) {
        FastScanner in = new FastScanner();
        byte vis[] =new byte[5005];
            int n = in.nextInt();

            int ans = 0;
            int t;
            for(int i=0;i<n;i++)
            {
                t= in.nextInt();
                if(t > n || vis[t]!=0)
                    ans++;
                else
                    vis[t] = 1;
            }
          System.out.println(ans);

    }

}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import static java.util.Collections.reverseOrder;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;

/**
 *
 * @author Ahmed_Naser
 */
public class HelloWorld {

    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();

        int matchboxes[] = new int[m];
        int matches[]= new int[m];

        for(int i = 0 ; i < m ; i++)
        {
            matchboxes[i] =in.nextInt();
            matches[i] = in.nextInt();
        }

        int max = matches[0];
        int index = 0 ;
        int count = 0 ;
        while( n > 0)
        {

           for( int j = 0 ; j < m ; ++j)
        {
            if( matches[j] >= max)
            {
                max= matches[j];
                index = j;

            }
        }
           if(  matchboxes[index] <= n)
           {
               n = n - matchboxes[index];
               count = count + (matches[index] * matchboxes[index] );
               matches[index] = 0 ;
           }
           else
           {

               count = count + (n * matches[index]);
               n = 0 ;
           }
           max = matches[0];
        }

        System.out.println(count);

    }
}


/**
 * ******* Created on 23/10/19 7:01 PM*******
 */

import java.io.*;
import java.util.*;

public class A8 implements Runnable {

    private void solve() throws IOException {
        String platform = reader.next();
        String first = reader.next();
        String second = reader.next();
        int n =platform.length();
        String[] output={"fantasy","forward", "backward", "both"};
        int mask =0;
        for(int l=0;l<2;l++){
            boolean flag =false;
            int index = platform.indexOf(first);
            if(index !=-1)
                flag =  platform.indexOf(second, index+first.length())!=-1;
            platform = new StringBuilder(platform).reverse().toString();
            if(flag ==true){
                mask |= (1<<l);
            }
        }
        writer.println(output[mask]);

    }

    public static void main(String[] args) throws IOException {
        try (Input reader = new StandardInput(); PrintWriter writer = new PrintWriter(System.out)) {
            new A8().run();
        }
    }

    StandardInput reader;
    PrintWriter writer;

    @Override
    public void run() {
        try {
            reader = new StandardInput();
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    interface Input extends Closeable {
        String next() throws IOException;

        default int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        default long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        default double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        default int[] readIntArray() throws IOException {
            return readIntArray(nextInt());
        }

        default int[] readIntArray(int size) throws IOException {
            int[] array = new int[size];
            for (int i = 0; i < array.length; i++) {
                array[i] = nextInt();
            }
            return array;
        }

        default long[] readLongArray(int size) throws IOException {
            long[] array = new long[size];
            for (int i = 0; i < array.length; i++) {
                array[i] = nextLong();
            }
            return array;
        }
    }

    private static class StandardInput implements Input {
        private final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        private StringTokenizer stringTokenizer;

        @Override
        public void close() throws IOException {
            reader.close();
        }

        @Override
        public String next() throws IOException {
            if (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                stringTokenizer = new StringTokenizer(reader.readLine());
            }
            return stringTokenizer.nextToken();
        }
    }
}

[{'input': 'atob\r\na\r\nb\r\n', 'output': ['forward\r\n']}, {'input': 'aaacaaa\r\naca\r\naa\r\n', 'output': ['both\r\n']}, {'input': 'aaa\r\naa\r\naa\r\n', 'output': ['fantasy\r\n']}, {'input': 'astalavista\r\nastla\r\nlavista\r\n', 'output': ['fantasy\r\n']}, {'input': 'abacabadabacaba\r\nabacaba\r\nabacaba\r\n', 'output': ['both\r\n']}, {'input': 'a\r\na\r\na\r\n', 'output': ['fantasy\r\n']}, {'input': 'ab\r\nb\r\na\r\n', 'output': ['backward\r\n']}, {'input': 'aaa\r\naaaa\r\naaaa\r\n', 'output': ['fantasy\r\n']}, {'input': 'bbabbbbababbaabaabaa\r\nabb\r\nbaab\r\n', 'output': ['forward\r\n']}, {'input': 'bbbbbbbbbbbbbbbbbbbbbbbbb\r\nbbbb\r\nbbbbb\r\n', 'output': ['both\r\n']}, {'input': 'babaabababaaaababaabababaabababababababbababbbabbaabababaababbaabbababaababaaabababaabbaababaaababaa\r\nabaabababaa\r\nabaabbaa\r\n', 'output': ['forward\r\n']}, {'input': 'bbbbbbbbbbbbbbbbbbbbbbbbb\r\nbbbb\r\nbbbbb\r\n', 'output': ['both\r\n']}, {'input': 'aababaaababaabbaabababaaababaabababbaabbabaabababaabbabbbababbababababababaabababaababaaaabababaabab\r\nabaabababaa\r\nabaabbaa\r\n', 'output': ['backward\r\n']}, {'input': 'aaaa\r\naaa\r\naa\r\n', 'output': ['fantasy\r\n']}, {'input': 'zzzz\r\nzz\r\nzzz\r\n', 'output': ['fantasy\r\n']}, {'input': 'zzzz\r\nzzzz\r\nzzzz\r\n', 'output': ['fantasy\r\n']}, {'input': 'zzzz\r\nzz\r\nzz\r\n', 'output': ['both\r\n']}, {'input': 'aabaa\r\naab\r\nbaa\r\n', 'output': ['fantasy\r\n']}, {'input': 'aabaab\r\naba\r\nab\r\n', 'output': ['forward\r\n']}, {'input': 'aab\r\nb\r\naa\r\n', 'output': ['backward\r\n']}, {'input': 'abacaba\r\naca\r\nba\r\n', 'output': ['both\r\n']}]