#include<bits/stdc++.h>
#define int long long int

#define f(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mod 1000000009
using namespace std;

int32_t main(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int n;cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++)cin>>a[i];
  int r=0;
  while(1){r++;
    sort(a.begin(),a.end());reverse(a.begin(),a.end());
    int c=0;
    for(int i=0;i<n/2;i++){
       if(a[i]==0)continue;
       else if(a[i]==1)a[i]=1;
       else a[i]=1;
       c++;
    }
    if(c!=n/2){
      if(r%2==1)cout<<"Bob";
      else cout<<"Alice";
      return 0;
    }

  }

return 0;
}


/*      __      __
 *  ____| |_____| |____
 * |                   |
 * |       __          |
 * |                   |
 * |    >       <.     |
 * |                   |
 * |                   |
 * |  ...  ⌒   ...     |
 * |                   |
 * |                   |
 * |___             __|
 *   |            |
 *   |            |   Code is far away from bug with the animal protecting
 *   |            |       神兽保佑，代码无bug
 *   |            |
 *   |            |_____
 *   |                  |
 *   |                  |_
 *   |                   _|
 *   |                   _|
 *   |__________________|
 *      | |        | |
 */
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <bitset>
#include <random>
#include <functional>
#include <unordered_map>
#define mset(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define fg cout << "--------------\n";
#define debug(x) std::cerr << #x << " = " << x << std::endl
#define All(x) (x.begin()), (x.end())
using namespace std;

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;
const ll INF = 1e18;

template <typename T> void read(T &x) {
	x = 0;
	int s = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')	s = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	x *= s;
}

template <typename T> void write(T x) {
	if (x < 0)	x = -x, putchar('-');
	if (x > 9)	write(x / 10);
	putchar(x % 10 + '0');
}

template <typename T> void writeln(T x) {
	write(x);
	puts("");
}

int n, a[55];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	rep(i, 0, n - 1)	read(a[i]);
	sort(a, a + n);
	if (a[0] == a[n - 1])	puts("Bob");
	else	puts("Alice");
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<map>
#include<vector>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

const int maxn=1000000+50;
const int inf=0x3f3f3f3f;

int main(){
    string s,ss;
    cin>>s;
    cin>>ss;
    int l=s.size();
    if(l<=1){
    	cout<<0<<endl;
return 0;
	}
	int vis=0;
    for(int i=0;i<l;){
    	if((s[i]=='0'&&s[i+1]=='0'&&(ss[i]=='0'||ss[i+1]=='0'))||(ss[i]=='0'&&ss[i+1]=='0'&&(s[i]=='0'||s[i+1]=='0'))){
    		vis++;
    		i+=2;
		}else i++;
	}
	cout<<vis<<endl;
	return 0;
}


#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
#define check(a) cout << a << endl;
#define cc(a) cout << a << endl;
#define msg(a,b) cout << a << " : " << b << endl;
#define msg2(a,b,c) cout << a << " : " << b << " : " << c << endl;

int main(){
    int i,sz,counter =0;
    string str1, str2;
    cin >> str1 >> str2;
    sz =str1.length();
    int arr[sz];
    for(i=0;i<sz;i++){
        arr[i] = 0;
    }
    for(i=0;i<sz;i++){
        if(str1[i] == '0'){
            arr[i] += 1;
        }
        if(str2[i] == '0'){
            arr[i] += 1;
        }
    }
/*
    for(i=0;i<sz;i++){
        cout << arr[i] << " ";
    }
    cout << endl;
*/
    for(i=0;i<sz-2;i++){
        if(arr[i] == 2 && arr[i+1] == 2 && arr[i+2] == 2){
            counter+=2;
            arr[i] = 0;
            arr[i+1] = 0;
            arr[i+2] = 0;
        }
    }
/*
    for(i=0;i<sz;i++){
        cout << arr[i] << " ";
    }
    cout << endl;
    */
    for(i=0;i<sz;i++){
        if(arr[i] == 2 && arr[i+1] == 2){
            arr[i] = 0;
            arr[i+1] = 1;
            counter++;
        }
        if(arr[i] == 2 && arr[i+1] == 1){
            arr[i] = 0;
            arr[i+1] = 0;
            counter++;
        }else if(arr[i] == 1 && arr[i+1] == 2){
            arr[i] = 0;
            arr[i+1] = 0;
            counter++;

        }
    }
    cout << counter << endl;

    return 0;
}


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

typedef long long int ll;
typedef pair <ll, ll> pll;

const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;

string str[5];
ll dp[102][6][6][102][102], n;

ll rec( ll idx, ll cur, ll prv, ll pos, ll cnt ) {
	//cout << idx << " " << n << endl;
 	if( idx > n ) {
		return 0;
	}
	ll &ret = dp[idx][cur][prv][pos][cnt];
	if( ~ret ) {
		return ret;
	}
	ret = 0;
	//cout << idx << "  " << prv << endl;
	if( str[1][idx] == '0' && str[2][idx] == '0' ) {
		if( idx < n && !( pos != idx - 1 && prv == 2 ) ) {
			if( str[1][idx+1] == '0' ) {
				ret = max( ret, rec( idx + 1, 1, cur, idx, cnt + 1 ) + 1 );
			}
		}
		if( idx < n && !( pos != idx - 1 && prv == 3 ) ) {
			if( str[2][idx+1] == '0' ) {
				ret = max( ret, rec( idx + 1, 4, cur, idx, cnt + 1 ) + 1 );
			}
		}
	}
	if( str[1][idx+1] == '0' && str[2][idx+1] == '0' && idx < n ) {
		if( !( pos != idx - 1 && prv == 1 ) ) {
			if( str[1][idx] == '0' ) {
				ret = max( ret, rec( idx + 1, 2, cur, idx, cnt + 1 ) + 1 );
			}
		}
		if( !( pos != idx - 1 && prv == 4 ) ) {
			if( str[2][idx] == '0' ) {
				ret = max( ret, rec( idx + 1, 3, cur, idx, cnt + 1 ) + 1 );
			}
		}
	} ret = max( ret, rec( idx + 1, 0, cur, pos, cnt ) );
	return ret;
}

int main() {
#ifdef Mr_Emrul
	freopen("inputf.in", "r", stdin);
#endif ///Mr_Emrul

	//ios_base::sync_with_stdio(false);
	//cin.tie(0);

	for( int i=1; i<=2; i++ ) {
		cin >> str[i];
	}
	n = str[1].size();
	str[1] = "#" + str[1];
	str[2] = "#" + str[2];
	memset( dp, -1, sizeof dp );
	ll ans = rec( 1,  0, 0, 0, 0 );
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
ll n;
set<ll> a;
void solve(ll ind,ll x)
{
    if (x==n)
    {
        a.insert(ind);
        return ;
    }
    if (x>n)
        return ;
    solve(ind,x+3);
    solve(ind+1,x+x+3);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
cin>>n;
solve(1,2);
cout<<a.size();
    return 0;
}


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

long long modulo=1073741824;
set<long long> s;
long long n;
void solve(long long x,long long val,long long counter)
{
    if(val==0)
    {
        s.insert(counter);
        return ;
    }
    if(x<2 || val<0)
    {
        return ;
    }
    if(x>n)
    {
        solve(x-3,val,counter);
        return ;
    }
    else
    {
        solve(x-3,val-x,counter+1);
        solve(x-3,val,counter);
    }

}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);

    cin>>n;
    solve(((n/3)*3)+2,n,0);
    cout<<s.size()<<endl;
    return 0;

}


#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <iterator>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long i64;
typedef unsigned long long ui64;
typedef vector<i64> vi64;
typedef long double ld;
#define forn(i, n) for(i64 i = 0; i < n; i++)
#define turn(i, n) for(i64 i = n - 1; i >= 0; i--)
#define FILESUKA "sth"
#define debug 5
ld PI = 3.141592653589793;
ld eps = 0.000000000000001;
i64 inf = 1000000000000;

int main()
{
    i64 n;
    cin >> n;
    vector<int> v;
    int k = 1;
    i64 res = 0;
    while (res < n)
    {
        res = 2 * k + (3 * ((k * (k - 1)) / 2));
        if (res < n)
            v.push_back(res);
        k++;
    }
    //k--;
    int count = 0;
    forn(i, k)
    {
        if (i == 0)
            continue;
        if ((n + i) % 3 == 0)
            count++;
    }
    cout << count;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef set<ll> sll;

#define out1(x)cout<<#x<<" is "<<x<<endl
#define out2(x,y)cout<<#x<<" is "<<x<<" "<<#y <<" is "<<y<<endl
#define out3(x,y,z)cout<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<" "<<#z<<" is "<<z<<endl;
#define out4(a,b,c,d)cout<<#a<<" is "<<a<<" "<<#b<<"  is "<<b<<" "<<#c<<" is "<<c<<" "<<#d<<" is "<<d<<endl;
#define show(i,a,n) for(i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define exectime() cout<<"execution time "<<(double)(clock() - tStart)/CLOCKS_PER_SEC<<endl;

#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define F first
#define S second
#define PI 3.14159265359
#define FastIn std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define swap(VAR1,VAR2) VAR1=VAR1^VAR2;VAR2=VAR1^VAR2;VAR1=VAR1^VAR2

const ll MAXN    = ll(5e6);
const ll INF     = ll(1e17);
const ld EPS     = ll(1e-9);
const ll MOD     = ll(1e9) + 7;
const ll MILLION = ll(1e6);
const ll BILLION = ll(1e9);
const ll ONE     = ll(1);

int main(){
    FastIn;
    clock_t tStart = clock();

    ll n,i,j,m,len;
    cin>>n;

    vector< pll > v;
    sll st;

    for(i=1;;i++){
        m = 2*i + (i-1);
        if(m > n)
            break;

        len = v.size();

        for(j = 0; j <len ;j++){

            if(m + ( v[j].F ) == n){
                st.insert(v[j].S);
            }

            if(m + v[j].F <n + 7)
            v.pb(mp(m + (v[j].F) ,v[j].S + 1));
        }

        v.pb(mp(m,1));

        if(m == n)
            st.insert(1);
    }

    n = int(st.size());

    cout<<n<<endl;
    //exectime();
    return 0;
}


#include <bits/stdc++.h>
#define lli long long int
#define endl "\n"
using namespace std;

int main()
{
	string s;
	cin>>s;
	int counter = 0;
	for(int i=0; i<s.length(); i++)
	{
		if((s[i] == '4') or (s[i] == '7'))
			counter++;
	}
	if(counter == s.length())
	{
		cout<<"YES";
	}
	else
	{
		int num;
		string sub = s.substr(s.length()-2,2);
		if(sub[0] != '0')
			num = stoi(sub);
		else
			num = (int)(sub[1]-'0');

		if(num%4 == 0)
			cout<<"YES";
		else
			cout<<"NO";
	}

	return 0;
}


#include <iostream>
#include "conio.h"
using namespace std;

int main()
{
	int n, chs, n1,c =0;
	cin >> n;
	bool sign = false;
	n1 = n;
	while (n1 > 0)
	{
		c++;
		n1 =  n1 / 10;
	}
	int mass[100] = { 4, 7, 44, 77, 47, 74, 444, 777, 744, 774, 447, 477, 747, 474 };
	if (c == 1)
	{
		for (int i = 0; i < 2; i++)
		{
			if ((n % mass[i]) == 0) sign = true;
		}
	}
	if (c == 2)
	{
		for (int i = 0; i < 6; i++)
		{
			if ((n % mass[i]) == 0) sign = true;
		}
	}
	if (c >= 3)
	{
		for (int i = 0; i < 14; i++)
		{
			if ((n % mass[i]) == 0) sign = true;
		}
	}
	if (sign) cout << "Yes";
	else cout << "No";
	_getch();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

vector<int> get_lucky(int n)
{
    vector<int> lucky_numbers;
    int m = 7;

    lucky_numbers.push_back(4);
    lucky_numbers.push_back(7);

    int len = 2;

    while (lucky_numbers[len - 1] <= n)
    {

        for (int i = 0; i < len; i++)
        {
            lucky_numbers.push_back(lucky_numbers[i] + 10*4);
            lucky_numbers.push_back(lucky_numbers[i] + 10*7);
        }
        len *= 2;
    }

    return lucky_numbers;
}

int main()
{
    int n;
    bool almost_lucky = false;

    std::cin >> n;

    vector<int> lucky_numbers = get_lucky(n);

    for (int i: lucky_numbers)
    {
        if (n % i == 0)
        {
            almost_lucky = true;
            break;
        }
    }

    std::cout << (almost_lucky ? "YES" : "NO") << std::endl;

}


#include <iostream>
#include <vector>

using namespace std;

vector<int> get_lucky(int &n)
{
    vector<int> lucky_numbers;
    int m = 7;

    lucky_numbers.push_back(4);
    lucky_numbers.push_back(7);

    int len = 2;

    while (lucky_numbers[len - 1] <= n)
    {

        for (int i = 0; i < len; i++)
        {
            lucky_numbers.push_back(lucky_numbers[i] + 10*4);
            lucky_numbers.push_back(lucky_numbers[i] + 10*7);
        }
        len += 2;
    }

    return lucky_numbers;
}

int main()
{
    int n;
    bool almost_lucky = false;

    std::cin >> n;

    vector<int> lucky_numbers = get_lucky(n);

    for (int i: lucky_numbers)
    {
        if (n % i == 0)
        {
            almost_lucky = true;
            break;
        }
    }

    std::cout << (almost_lucky ? "YES" : "NO") << std::endl;

}


/*..
    I can't sleep at night
'Cause she ain't by my side....*/

    #include <bits/stdc++.h>
    using namespace std;
    //g++ code.cpp -o ./x
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define fr(a,b,c) for(ll a=b;a>=c;a--)
    #define mod 1000000007
    #define int long long
    #define read(t) ll t;cin>>t;
    #define rs(t) string t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define pii pair<ll,ll>
    #define dbg(x) cout<<#x<<" = "<<x<<endl;
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define INF (ll)1<<30;

/*__builtin_popcount(n)
ac a=97,A=65*/
ll binpow(ll x, ll y,ll mo)
{
    ll res = 1;
    x = x ;
    while (y > 0)
    {
        if (y & 1)res = (res*x)%mo;
        y = y>>1;
        x = (x*x);
    }
    return res%mo;
}
/**********************************************************************************************************************/

signed main()
{
    fast;
    ll l,r;
    cin>>l>>r;
    if(l==r)
    {
        cout<<0<<endl;
        return 0;
    }
    else
    {
        ll bit[63][2];
        for(ll i=63;i>=0;i--)
        {
            if(l&(1<<i))bit[i][0]=1;
            else bit[i][0]=0;
            if(r&(1<<i))bit[i][1]=1;
            else bit[i][1]=0;
        }
        for(ll i=62;i>=0;i--)
        {
            if(bit[i][1]>bit[i][0])
            {
                cout<<(1<<(i+1))-1<<endl;
                return 0;
            }
        }
    }
}


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

#define ll long long int
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#define mp make_pair
#define mt make_tuple
#define one(x) memset(x,1,sizeof(x))
#define zero(x) memset(x,0,sizeof(x))
#define ri(x) scanf("%d", &x)
#define rl(x) scanf("%llu", &x)
#define rc(x) scanf("%c", &x)
#define rs(x) scanf("%s", x.c_str())
#define printi(x) printf("%d ", x)
#define printl(x) printf("%lld ", x)
#define prints(x) printf("%s", x)
#define nl printf("\n")
#define VI vector<int>
#define VL vector<ll>
#define VS vector<string>
#define VC vector<char>
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define TI tuple<int, int, int>
#define TL tuple<ll, ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define VTI vector<TI>
#define VTL vector<TL>

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

unsigned long long bin(int x){
	if(x == 0) return 1LL;
	unsigned long long ans = bin(x / 2);
	ans = ans * ans;
	if(x & 1) ans = ans * 2;
	return ans;
	}
int main(){
	unsigned ll l, r;
	rl(l); rl(r);
	if(l == r){
		printf("0");
		return 0;
		}
	bitset<60> L(l), R(r);
	string A = L.to_string();
	string B = R.to_string();
	int pos= 0;
	do{
			++pos;
	}
	while(pos <60 && B[pos] == A[pos]);
	unsigned long long res = (L.to_ulong() |  bin(60 - pos) - 1);
	cout <<res<< endl;
	return 0;
}


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

//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define fo(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define foe(i,x) for(auto& i: x)
#define ar array
#define pb push_back
#define vt vector
#define F first
#define S second

template<class T> bool umin(T& a,const T& b){return b<a?a=b,1:0;}
template<class T> bool umax(T& a,const T& b){return b>a?a=b,1:0;}

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {cin>>x;}
void read(double& d) {string t;read(t);	d=stod(t);}
void read(long double& d) {	string t;read(t);d=stold(t);}
template<class H, class... T> void read(H& h, T&... t) {read(h);read(t...);}
template<class A> void read(vt<A>& x) {	foe(a, x)read(a);}
int nxt(){int a;read(a);return a;}   // iota(all(v),0); genrate(all(v),nxt);

// no change
const ll MOD = 1e9+7;
void Titan(){
	ll l ,r;
	read(l,r);
	if(l==r){
		cout << 0;
		return;
	}
	bitset<63> L(l),R(r),ans;
	int k;
	for(int i = 62;i>=0;i--){
		if(L[i]!=R[i]){
			k = i+1;
			break;
		}
	}

	int i = 0;
	while(k--){
		ans.set(i++);
	}
	cout<< ans.to_ulong();
	/*ll a;
	int k = 63;
	while(k>=0 && ((1<<k)&l) == ((1<<k)&r)){
		k--;
	}
	k++;
	a =(ll)(1<<k)-1;
	if(l==r){
		cout << 0;
		return;
	}
	cout <<a;
	*/

}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T = 1;
	//cin >> T;		//cmt if one test case
    fo(T){
		//cout << "Case #" << i+1 << ": " ;
		Titan();
	}
}
/*///////////////////////////////////////////////////////////
Important Notes :
* check long long
* check base cases
* do not loose Hope
* if case fails on 2nd test case maybe some cases are missing check them
* do not sit idle
* try to do it using pen/paper.
*/


#include "bits/stdc++.h"

#define ll long long
#define ull unsigned long long
#define ld long double

#define tiii tuple < int, int, int >
#define pii pair < int, int >
#define pll pair < ll, ll >
#define pci pair < char, int >
#define psi pair < string, int >
#define pis pair < int, string >

#define vi vector < int >
#define vd vector < double >
#define vld vector < ld >
#define vll vector < ll >
#define vs vector < string >
#define vc vector < char >
#define vpi vector < pii >
#define vpll vector < pll >
#define vpis vector < pis >

#define pb push_back
#define mt make_tuple
#define gt0 get < 0 >
#define gt1 get < 1 >
#define gt2 get < 2 >

#define pi acos(-1)

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    fast;

    ll k, a, b, v;

    cin >> k >> a >> b >> v;

    ll mn = (b, v - 1);
    ll d = (b / mn), r = (b % mn);
    ll tot = (d * (mn + 1) * k) + ((r + 1) * k);
    ll ans = d + r;

    if(tot >= a){
        cout << ans << endl;
        return 0;
    }

    ll baki = (a - tot);
    ans += (baki / k);

    if(baki % k) ans++;

    cout << ans << endl;

    return 0;
}


#include <iostream>
using namespace std;

main()
{
	freopen("input", "r", stdin);
	ios::sync_with_stdio(0);
	int k, a, b, v;
	cin >> k >> a >> b >> v;
	int x = (a + v - 1) / v;
	int ans = 0;
	while (x > 0)
	{
		int y = min(x, min(b + 1, k));
		x -= y;
		b -= y - 1;
		ans ++;
	}
	cout << ans << "\n";
}


#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
    long long k,a,b,v,i=0,j,l,p;
	cin>>k>>a>>b>>v;
    if(b+1>=k)
	{
		while(a>0)
	    {
		    a-=k*v;
			b-=k-1;
		    i++;
	    }
	}
	else
	{
		a-=(b+1)*v;
		i++;
		while(a>0)
	    {
         a-=v;
		 i++;
		}
	}
	cout<<i;
	_getch();
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int a,b,c,ans=0,k,v,i;
    scanf("%d%d%d%d", &k, &a, &b, &v);
    while(b>k-1 && a>=0)
    {
        a-=k*v;
        b-=k-1;
        ans++;
    }
    if(a>0)
    {
        c=b*v+v;
        a-=c;
        ans++;
    }
    if(a>0)
    {
        if(a%v==0)
            ans+=a/v;
        else
            ans+=a/v+1;
    }
    printf("%d\n", ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct edge{
	short to,cap,rev;
	edge(int _a=0,int _b=0,int _c=0){
		to=_a;
		cap=_b;
		rev=_c;
	}
};
int S,T;
int dist[10010];
int cur[10010];
vector<edge> adj[10010];
int q[10010];
int hd,tl;
inline void addedge(int u,int v,int cap){
	adj[u].push_back(edge(v,cap,adj[v].size()));
	adj[v].push_back(edge(u,0,adj[u].size()-1));
}
int dfs(int i,short fl){
	if (i==T) return fl;
	short lf=fl;
	for (int &j=cur[i];~j;--j){
		edge &e=adj[i][j];
		if (e.cap&&dist[e.to]==dist[i]+1){
			short d=dfs(e.to,min(lf,e.cap));
			e.cap-=d;
			adj[e.to][e.rev].cap+=d;
			lf-=d;
			if (!lf) return fl;
		}
	}
	dist[i]=-1;
	return fl-lf;
}
int Dinic(){
	int res=0;
	while(true){
		memset(dist,0,sizeof(dist));
		dist[q[hd=tl=0]=S]=1;
		while(hd<=tl){
			int i=q[hd++];
			cur[i]=adj[i].size()-1;
			for (int j=cur[i];~j;--j){
				edge &e=adj[i][j];
				if (e.cap&&!dist[e.to]){
					dist[e.to]=dist[i]+1;
					q[++tl]=e.to;
				}
			}
		}
		if (!dist[T]) break;
		int fl;
		while(fl=dfs(S,10000)) res+=fl;
	}
	return res;
}
int bel[5010];
int tpe[5010];
int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	S=0;
	T=n+m+1;
	for (int i=1;i<=n;++i){
		int a,b,c;
		scanf("%d%d",&tpe[i],&a);
		switch(tpe[i]){
			case 0:{
				while(a--){
					scanf("%d",&b);
					addedge(i,b+n,1);
				}
				break;
			}
			case 1:{
				scanf("%d",&b);
				for (int j=a;j<=b;++j){
					addedge(i,j+n,1);
				}
				break;
			}
			case 2:{
				scanf("%d%d",&b,&c);
				addedge(i,a+n,1);
				addedge(i,b+n,1);
				addedge(i,c+n,1);
				break;
			}
		}
	}
	for (int i=1;i<=n;++i){
		if (tpe[i]!=2){
			addedge(S,i,1);
		}
	}
	for (int i=1;i<=n;++i){
		if (tpe[i]==2){
			addedge(S,i,2);
		}
	}
	for (int i=1;i<=m;++i){
		addedge(n+i,T,1);
	}
	printf("%d\n",Dinic());
	for (int i=1;i<=m;++i){
		for (int j=adj[i+n].size()-1;~j;--j){
			edge &e=adj[i+n][j];
			if (e.cap&&e.to!=T){
				bel[i]=e.to;
			}
		}
	}
	for (int i=1;i<=m;++i){
		if (bel[i]) printf("%d %d\n",bel[i],i);
	}
	return 0;
}


#include<bits/stdc++.h>
#define N 100005
#define inf 0x3f3f3f3f
#define lc (p<<1)
#define rc (p<<1|1)
#define mid (l+r>>1)
using namespace std;
inline int read(){
	int ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
char xxx;
bool vis[N];
int n,m,id[N],tot,Begin,ans;
struct edge{int v,c,next;};
map<int,int>mp[N];
int d[N],first[N],cnt,s,t;
edge e[N];
inline void add(int u,int v,int c){
	e[++cnt].v=v,e[cnt].c=c,e[cnt].next=first[u],first[u]=cnt;
	e[++cnt].v=u,e[cnt].c=0,e[cnt].next=first[v],first[v]=cnt;
}
inline bool bfs(){
	queue<int>q;
	fill(d+1,d+t+1,-1),q.push(s),d[s]=0;
	while(!q.empty()){
		int x=q.front();
		q.pop();
			for(int i=first[x];i;i=e[i].next){
			int v=e[i].v;
			if(!e[i].c||~d[v])continue;
			d[v]=d[x]+1,q.push(v);
				if(v==t)return true;
		}
	}
	return false;
}
inline int dfs(int p,int f){
		if(!f||p==t)return f;
	int flow=f;
	for(int i=first[p];i;i=e[i].next){
		int v=e[i].v;
		if(!flow)break;
			if(!e[i].c||d[v]!=d[p]+1)continue;
		int tmp=dfs(v,min(flow,e[i].c));
		if(!tmp)d[v]=-1;
		e[i].c-=tmp,e[i^1].c+=tmp,flow-=tmp;
	}
	return d[p]=-1,f-flow;
}
inline void solve(){while(bfs())ans+=dfs(s,inf);}
inline void build(int p,int l,int r){
	id[p]=++tot;
	if(l==r){add(id[p],l,1);return;}
	build(lc,l,mid),build(rc,mid+1,r);
	add(id[p],id[lc],inf),add(id[p],id[rc],inf);
}
inline void update(int p,int l,int r,int ql,int qr){
	if(ql>r||qr<l)return;
	if(ql<=l&&r<=qr){add(tot,id[p],1);return;}
	if(qr<=mid)update(lc,l,mid,ql,qr);
	else if(ql>mid)update(rc,mid+1,r,ql,qr);
	else update(lc,l,mid,ql,mid),update(rc,mid+1,r,mid+1,qr);
}
inline int query(int p){
	if(p>=Begin){return p-Begin+1;}
	map<int,int>::iterator it=mp[p].begin();
	int ret=query(it->first);
	--it->second;
	if(!it->second)mp[p].erase(it);
	return ret;
}
int main(){
	n=read(),tot=m=read(),cnt=1,s=++tot,build(1,1,m),Begin=tot+1;
	for(int i=1;i<=n;++i){
		int op=read();
		++tot;
		if(op==0){
			int k=read();
			while(k--){
				int x=read();
				add(tot,x,1);
			}
			add(s,tot,1);
		}
		else if(op==1){
			int ql=read(),qr=read();
			update(1,1,m,ql,qr),add(s,tot,1);
		}
		else{
			int a=read(),b=read(),c=read();
			vis[a]=vis[b]=1,ans+=2;
			add(tot,a,0),e[cnt].c=1,add(tot,b,0),e[cnt].c=1,add(tot,c,1);
		}
	}
	t=++tot;
	for(int i=1;i<=m;++i)if(!vis[i])add(i,t,1);
	solve();
	printf("%d\n",ans);
	for(int i=1;i<=tot;++i)for(int j=first[i];j;j=e[j].next)if((j&1)&&e[j].c)mp[i][e[j].v]=1;
	for(int i=1;i<=m;++i){
		bool f=true;
		for(int j=first[i];j&&f;j=e[j].next)if(e[j].v==t&&e[j].c)f=false;
		if(f)printf("%d %d\n",query(i),i);
	}
	return 0;
}


//#define _GLIBCXX_DEBUG
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,fma")
#pragma GCC optimize("unroll-loops")
*/
/*
　　　　　／＞　 フ
　　　　　| 　_　 _|
　 　　　／`ミ _x 彡      КАК ЖЕ МНЕ НАДОЕЛА ЭТА ПРОГА ТУПАЯ ГОСПОДИ
　　 　 /　　　 　 |
　　　 /　  ヽ　　 ﾉ
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)_)
　＼二つ
 */

#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;
#define ll long long
#define fi first
#define se second
mt19937 gen(time(0));
bool IS_ONE_TEST = 1;
struct edge {
  ll v, flow, cap, link, idx;
  edge(ll v, ll flow, ll cap, ll link, ll idx):
    v(v), flow(flow), cap(cap), link(link), idx(idx){};
  edge(){};
};
vector<vector<edge>> g;
vector<int> mark;
void make_edge(int v, int u, ll w1, ll w2, int idx) {
  g[v].emplace_back(u, 0, w1, g[u].size(), idx);
  g[u].emplace_back(v, 0, w2, g[v].size() - 1, -1);
}
ll dfs(int v, ll cur_flow, int step, int term) {
  if (v == term) return cur_flow;
  if (mark[v] == step) return 0;
  mark[v] = step;
  for (auto &e : g[v]) {
    if (mark[e.v] != step && e.flow < e.cap) {
      ll res = dfs(e.v, min(cur_flow, e.cap - e.flow), step, term);
      if (res == 0) continue;
      e.flow += res;
      g[e.v][e.link].flow -= res;
      return res;
    }
  }
  return 0;
}
ll max_flow(ll s, ll t) {
  ll flow = 0;
  int step = 1;
  while (true) {
    ll res = dfs(s, 1e9, step++, t);
    if (!res) break;
    flow += res;
  }
  return flow;
}
void remove_flow(int v) {
  for (auto &e : g[v]) {
    if (e.idx != -1) continue;
    if (e.flow == e.cap) continue;
    e.flow += 1;
    g[e.v][e.link].flow -= 1;
    remove_flow(e.v);
    return;
  }
}
void solve() {
  int n, m;
  cin >> n >> m;
  g.resize(n + m + 2);
  mark.assign(n + m + 2, -1);
  vector<int> OMG(n);
  vector<int> is_used(m);
  for (int i = 0; i < n; ++i) {
    int t, k, l, r;
    cin >> t;
    if (t == 0) {
      make_edge(n + m, i, 1, 0, n + m);
      cin >> k;
      for (int j = 0; j < k; ++j) {
        cin >> l;
        make_edge(i, l - 1 + n, 1, 0, i);
      }
    }
    else if (t == 1) {
      make_edge(n + m, i, 1, 0, n + m);
      cin >> l >> r;
      for (int j = l - 1; j <= r - 1; ++j) {
        make_edge(i, j + n, 1, 0, i);
      }
    }
    else {
      cin >> k >> l >> r;
      OMG[i] = 1;
      make_edge(n + m, i, 2, 0, n + m);
      make_edge(i, k - 1 + n, 1, 0, i);
      make_edge(i, l - 1 + n, 1, 0, i);
      make_edge(i, r - 1 + n, 1, 0, i);
    }
  }
  for (int i = n; i < n + m; ++i) make_edge(i, n + m + 1, 1, 0, n + m + 1);
  ll res = max_flow(n + m, n + m + 1);
  for (int i = 0; i < n; ++i) {
    if (OMG[i]) {
      int cur_flow = 0;
      for (auto &e : g[i]) {
        if (e.idx != -1) {
          cur_flow += e.flow;
        }
      }
      //cout << i << " : " << cur_flow << endl;
      for (auto &e : g[i]) {
        if (cur_flow == 2 || e.idx == -1 || e.flow == e.cap) continue;
        remove_flow(e.v);
        e.flow += 1;
        g[e.v][e.link].flow -= 1;
        ++cur_flow;
      }
    }
  }
  cout << res << endl;
  for (int i = n; i < n + m; ++i) {
    for (auto &e : g[i]) {
      if (e.idx != -1 || e.flow == 0) continue;
      cout << e.v + 1 << " " << i - n + 1 << endl;
      break;
      //cout << e.v << " -> " << i << " with " << e.flow << endl;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(15);
  ll t;
  if (IS_ONE_TEST)
    t = 1;
  else
    cin >> t;
  while (t-->0) {
    solve();
  }
}


#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 119 << 23 | 1;
const int INF = (int) 1e9 + 23111992;
const ll LINF = (ll) 1e18 + 23111992;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ull isqrt(ull k) {ull r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int myrand() {return abs((int) mt());}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

#define MF Maxflow
#define flow_t int
const flow_t foo = (flow_t) 1e9;
namespace Maxflow {
    const int maxv = 1e5 + 5;
    const int maxe = 3e7 + 5;
    int n, s, t, E;
    int adj[maxe], nxt[maxe], lst[maxv], ptr[maxv], lev[maxv], que[maxv];
    flow_t flw[maxe], cap[maxe];
    void init(int nn, int ss, int tt) {
        n = nn, s = ss, t = tt, E = 0;
        fill_n(lst, n, -1);
    }
    int add(int u, int v, flow_t c1, flow_t c2) {
        adj[E] = v, flw[E] = 0, cap[E] = c1, nxt[E] = lst[u], lst[u] = E++;
        adj[E] = u, flw[E] = 0, cap[E] = c2, nxt[E] = lst[v], lst[v] = E++;
        return E - 2;
    }
    int bfs() {
        fill_n(lev, n, 0), lev[s] = 1;
        int qsize = 0;
        que[qsize++] = s;
        for (int i = 0; i < qsize; i++) {
            for (int u = que[i], e = lst[u]; ~e; e = nxt[e]) {
                int v = adj[e];
                if (flw[e] < cap[e] && !lev[v]) {
                    lev[v] = lev[u] + 1;
                    que[qsize++] = v;
                }
            }
        }
        return lev[t];
    }
    flow_t dfs(int u, flow_t bot) {
        if (u == t) return bot;
        for (int& e = ptr[u]; ~e; e = nxt[e]) {
            int v = adj[e];
            flow_t delta = 0;
            if (lev[v] == lev[u] + 1 && flw[e] < cap[e] && (delta = dfs(v, min(bot, cap[e] - flw[e]))) > 0) {
                flw[e] += delta; flw[e ^ 1] -= delta;
                return delta;
            }
        }
        return 0;
    }
    flow_t maxflow(int ss = -1, int tt = -1) {
        if (~ss) s = ss;
        if (~tt) t = tt;
        fill_n(flw, E, 0);
        flow_t total = 0;
        while (bfs()) {
            for (int i = 0; i < n; i++) ptr[i] = lst[i];
            for (flow_t delta = dfs(s, foo); delta > 0; delta = dfs(s, foo)) total += delta;
        }
        return total;
    }
    vector<pair<pair<int, int>, flow_t> > gomory_hu() {
        vector<pair<pair<int, int>, flow_t> > tree;
        vector<int> p(n);
        for (int u = 1; u < n; u++) {
            tree.push_back(make_pair(make_pair(p[u], u), maxflow(u, p[u])));
            for (int v = u + 1; v < n; ++v) {
                if (lev[v] && p[v] == p[u]) {
                    p[v] = u;
                }
            }
        }
        return tree;
    }
}

void chemthan() {
    int n, m; cin >> n >> m;
    int tot = n + m, s = tot++, t = tot++;
    MF::init(tot, s, t);
    static int id[5005][5005];
    ms(id, -1);
    static int tp[5005];
    static vi g[5005];
    FOR(i, 0, n) {
        int t; cin >> t;
        tp[i] = t;
        if (t == 0) {
            MF::add(s, i, 1, 0);
            int k; cin >> k;
            while (k--) {
                int u; cin >> u; u--;
                id[i][u] = MF::add(i, n + u, 1, 0);
            }
        }
        else if (t == 1) {
            MF::add(s, i, 1, 0);
            int l, r; cin >> l >> r; l--, r--;
            FOR(j, l, r + 1) {
                id[i][j] = MF::add(i, n + j, 1, 0);
            }
        }
        else if (t == 2) {
            MF::add(s, i, 2, 0);
            int a, b, c; cin >> a >> b >> c; a--, b--, c--;
            id[i][a] = MF::add(i, n + a, 1, 0);
            id[i][b] = MF::add(i, n + b, 1, 0);
            id[i][c] = MF::add(i, n + c, 1, 0);
            g[i].pb(a);
            g[i].pb(b);
            g[i].pb(c);
        }
    }
    FOR(i, 0, m) MF::add(n + i, t, 1, 0);
    cout << MF::maxflow() << "\n";
    static int to[5005];
    static int from[5005];
    ms(to, -1), ms(from, -1);
    FOR(i, 0, n) {
        if (tp[i] == 2) {
            vi vals;
            map<int, int> used;
            FOR(j, 0, m) {
                if (MF::flw[id[i][j]] > 0) {
                    vals.pb(j);
                    used[j] = 1;
                }
            }
            if (sz(vals) && sz(vals) < 2) {
                for (int u : g[i]) {
                    if (!used[u]) {
                        from[u] = 0;
                        vals.pb(u);
                        break;
                    }
                }
            }
            for (int u : vals) {
                cout << i + 1 << " " << u + 1 << "\n";
            }
        }
    }
    FOR(i, 0, n) {
        if (tp[i] != 2) {
            FOR(j, 0, m) {
                if (MF::flw[id[i][j]] > 0) {
                    if (from[j] == -1) {
                        cout << i + 1 << " " << j + 1 << "\n";
                    }
                }
            }
        }
    }
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


#include <bits/stdc++.h>
int main(){
    for(int i=21;i<=50;++i,puts(""))
        std::cout<<((std::min(i,25)+i)%((i%3))>-2);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	for(int i=21;i<=50;i++)
		scanf("%lld",((min(i,25)+i)%(2+i%3)>0)?1:0);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	for(int i=21;i<=50;i++)
		scanf("%lld",((min(i,25)+i)%(2+i%3)>0));
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
	for(int k=21;k=50;k++)
	{
		cout<<(((min(k,25)+k)%(2+k%3)>0)?1:0)<<endl;
	}
	return 0;
}


#include <conio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
int main()
{
    int n,k,free=0,foll=0,res=0,temple=0,unic=0,ununic=0;
    cin>>n>>k;
    n=8*n;
    int x=n/2,y=n/2;
     int *arr=new int[k];
     int x1=0,x2=0,x3=0,x0=0;
    for(int i=0;i<k;i++)
    {
        arr[i]=0;
        cin>>arr[i];
        res=res+arr[i];
       if(arr[i]%2==0)
       {
           x0=x0+arr[i]/4;
           x2=x2+arr[i]%4;
       }
        if(arr[i]%4==1)
        {
            x1++;
        }
        if(arr[i]%4==1||arr[i]%4==3&&arr[i]!=1)
        {
            ununic++;
        }
        if(arr[i]==1)
        {
            unic++;
        }
        if(arr[i]%4==3)
        {
            x3++;
        }
        if(arr[i]==1)
        {
            free=free+1;
        }
    }
    if(abs(y-x2)!=0)
    {
       if(abs(y-x2)%4!=0&&y>x2)
       {
          foll=foll+1;
       }
    }
    if(x3+x1>0)
    {

            foll=foll+x3+x1-1;

    }
if(y<x2)
{
    if((x2-y)%4==0)
    {
       foll=foll+(x2-y)/4;
    }
    if((x2-y)%4==2)
    {
        foll=foll+(x2-y)/4+1;
    }
    if((y-x2)/2==free)
    {
         foll=0;
        foll=free;
    }

}
    //sort(arr,arr+k,greater<int>());
if(unic>0&&y<x2)
{
    foll=min((x2-y)/2,unic);

}

if(res+foll<=n)
{
    cout<<"Yes";
}
else
{
    cout<<"No";
}

//cout<<foll;
//cout<<foll;
    getch();
    return 0;

}
//


#include <conio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
int main()
{
    int n,k,free=0,foll=0,res=0,temple=0;
    cin>>n>>k;
    n=8*n;
    int x=n/2,y=n/2;
     int *arr=new int[k];
     int x1=0,x2=0,x3=0,x0=0;
    for(int i=0;i<k;i++)
    {
        arr[i]=0;
        cin>>arr[i];
        res=res+arr[i];
       if(arr[i]%2==0)
       {
           x0=x0+arr[i]/4;
           x2=x2+arr[i]%4;
       }
        if(arr[i]%4==1)
        {
            x1++;
        }
        if(arr[i]%4==3)
        {
            x3++;
        }
    }
    if(abs(y-x2)!=0)
    {
       if(abs(y-x2)%4!=0&&y>x2)
       {
          foll=foll+1;
       }
    }
    if(x3+x1>0)
    {
        foll=foll+x3+x1-1;
    }
if(y<x2)
{
    if((x2-y)%4==0)
    {
       // foll=foll+(x2-y)/4;
    }
    if((x2-y)%4==2)
    {
        foll=foll+(x2-y)/4+1;
    }

}
    //sort(arr,arr+k,greater<int>());

if(res+foll<=n)
{
    cout<<"Yes";
}
else
{
    cout<<"No";
}
//cout<<res+foll;
//cout<<foll;
    getch();
    return 0;

}
//


#include <iostream>
#include <conio.h>
#include <cmath>
using namespace std;
int main()
{
    int k,n,i,free=0;
    cin>>n;
    cin>>k;
    n=8*n;
    int x=n/2,y=n/2;
int *ar=new int[k];
for(i=0;i<k;i++)
{
    ar[i]=0;
    cin>>ar[i];
}
for(i=0;i<k-1;i++)
{
    if(x>0)
    {
            if(ar[i]%2==0)
        {
            x=x-ar[i];
        }
        if(ar[i]%2==1)
        {
            x=x-ar[i]-1;
        }
    }
    else
    {
         if(ar[i]%4==0)
        {
            y=y-ar[i];
        }
        if(ar[i]%4==1)
        {
            y=y-ar[i]-1;
        }
         if(ar[i]%4==2)
        {
            y=y-ar[i]-1;

        }
        if(ar[i]%4==3)
        {
            y=y-ar[i]-1;

        }
    }

}
if(y<n/2)
{
	y=y-ar[k-1];
}

if(y-abs(x)>0)
{
    cout<<"Yes";
}
else
{
     cout<<"No";
}
cout<<y-abs(x);
getch();
return 0;
}


#include <iostream>

using namespace std;

int main()
{
  unsigned int w, h, u1, d1, u2, d2;
  cin >> w >> h;
  cin >> u1 >> d1;
  cin >> u2 >> d2;
  while(h>0)
  {
      w+=h;
      if (h==d1) w-=u1;
      else if (h==d2) w-=u2;
      if (w < 0) w = 0;
      h--;
  }
  cout << w;
  return 1;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int arr[1000005];
ll pow_mod(ll a, ll b, ll M)
{   ll ans = 1LL;
    while (b > 0) {
        if ( b%2 == 1) {
            ans=(ans * a)% M;
        }
        a = (a * a)%M;
        b = b / 2;
    }
    return ans;
}
void sieve(int n)
{
    int i, p;
    for(i = 0;i <= n; i++)
          arr[i] = i;
    for(p = 2;p <= n; p++)
    {
        if(arr[p] == p)
        {
            for(i = p;i<= n;i += p)
            {
                arr[i] = p;
            }
        }
    }

}
int main()
{
    #ifdef ONLINE_JUDGE
    // Assume input.txt and output.txt suitably exists
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    ll i,w,h,u1,u2,d1,d2,dm,dmn;
    //long long int pre[100001]={0};

    cin>>w>>h;
    cin>>u1>>d1;
    cin>>u2>>d2;

    dm = max( d1, d2);
    //w += ( pre[h] - pre[dm-1] );
    (dm == d1) ? w -= u1 : w -= u2;
    if(w < 0) w = 0;

    dmn = min(d1,d2);
    //w += (pre[dm-1] - pre[dmn-1]);
    (dmn == d1) ? w -= u1 : w -= u2;
    if(w < 0) w = 0;

    //w += (pre[dmn - 1]);
    cout<<w<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int arr[1000005];
ll pow_mod(ll a, ll b, ll M)
{   ll ans = 1LL;
    while (b > 0) {
        if ( b%2 == 1) {
            ans=(ans * a)% M;
        }
        a = (a * a)%M;
        b = b / 2;
    }
    return ans;
}
void sieve(int n)
{
    int i, p;
    for(i = 0;i <= n; i++)
          arr[i] = i;
    for(p = 2;p <= n; p++)
    {
        if(arr[p] == p)
        {
            for(i = p;i<= n;i += p)
            {
                arr[i] = p;
            }
        }
    }

}
int main()
{
    #ifdef ONLINE_JUDGE
    // Assume input.txt and output.txt suitably exists
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    ll i,w,h,u1,u2,d1,d2,dm,dmn,pre[100001]={0};
    for(i=1;i<100001;i++)
    {
        //pre[i] += (pre[i - 1] + i);
    }
    cin>>w>>h;
    cin>>u1>>d1;
    cin>>u2>>d2;

    dm = max( d1, d2);
    cout<<h<<" "<<dm-1<<"\n";
    //w += ( pre[h] - pre[dm-1] );
    (dm == d1) ? w -= u1 : w -= u2;
    if(w < 0) w = 0;

    dmn = min(d1,d2);

    cout<<dm-1<<" "<<dmn-1<<"\n";
    //w += (pre[dm-1] - pre[dmn-1]);
    (dmn == d1) ? w -= u1 : w -= u2;
    if(w < 0) w = 0;

    //w += (pre[dmn - 1]);
    cout<<w<<" ";
    return 0;
}


#include <bits/stdc++.h>  // This will work only for g++ compiler.

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based

//short hand for usual tokens
#define pb push_back
#define fi first
#define se second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

// traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)

// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c,x) ((c).find(x) != (c).end())

//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())

// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) int((a).size())
#define INF 0x3f3f3f3f

using namespace std;

// Shorthand for commonly used types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
    int n;
	cin>>n;
	vector<char>isprime(n+1 , true);
	vector<int> primes;
	isprime[0] = isprime[1] = false;
	isprime[2] = true;
	primes.pb(2);
	for(int i =3;i*i <= n;i+2)
	{
		if(isprime[i])
		{
            primes.pb(i);
			for(int j = i*i ; j*j<=n;j+=i)
			{
				isprime[j] = false;
			}
		}
	}
	int count = 0;
	for(int q : primes)
	{
		if(primes[0]*primes[q-1] == n)
		{
			count++;
		}
	}
	cout<<count<<"\n";
    return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    //freopen("in.txt", "r", stdin);
    int n, i, j, count = 0, res = 0;
    scanf("%d", &n);
    vector <int> v;
    for (i = 1; i <= n; ++i)
    {
        count = 0;
        for (j = 1; j < i; ++j)
        {
            if (i % j == 0 && (j <= 5 || j % 5 != 0) && (j == 2 || j == 3 || (j > 3 && (j * j - 1) % 24 == 0)) && find(v.begin(), v.end(), j) == v.end())
            {

                ++count;
                v.push_back(j);
            }
        }
        if (count == 2)
        {
            ++res;
            //printf("%d %d\n", v[0], v[1]);
        }
        v.clear();
    }
    printf("%d", res);
    return 0;
}


#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

bool prime_fun (int j)
{
    if(j == 1)
        return false;
    for(int i = 2 ; i < j ; i++)
        if(j % i == 0)
            return false;
    return true;
}
int Total_prime(int n)
{
    int cnt = 0 ;

    for(int i = 2 ; i<= n/2 ; i++)
    {
        if(n % i == 0)
        {
            if(prime_fun(i))
                cnt++ ;
        }
    }
    return cnt ;
}
int main()
{
    //ifstream cin ("A.in");
    int T , res = 0 ;

    cin >> T;
    if(T < 6)
        cout << "0" << endl ;
    for(int k = 6 ; k <= T ; k++)
    {
        if(Total_prime(k) == 2)
            res++ ;

    }
    cout << res << endl ;
return 0;
}


#include <bits/stdc++.h>

#define debug(...) clog << "[" << #__VA_ARGS__ << "]", debug_out(__VA_ARGS__)
#define all(v)      (v).begin(), (v).end()
#define rall(v)     (v).rbegin(), (v).rend()
#define endl '\n'
using namespace std;
using ll = long long;

void debug_out() {clog << endl;}

template <typename H, typename... T>
void debug_out(H head, T... tail)
{
    clog << " " << head;
    debug_out(tail...);
}

template <typename T>
ostream& operator<<(ostream &os, const vector<T> &vec)
{
    for(auto &i : vec)
        os << i << ' ';
    return os;
}

template <typename T>
ostream& operator<<(ostream &os, const vector<vector<T>> &vec)
{
    if(!vec.empty())
        os << vec[0];
    for(size_t i = 1; i < vec.size(); ++i)
        os << '\n' << vec[i];
    return os;
}

template <typename T, typename U>
ostream& operator<<(ostream &os, const pair<T,U> &p)
{
    os << p.first << ' ' << p.second;
    return os;
}

template <typename T>
ostream& operator<<(ostream &os, const set<T> &s)
{
    for(auto &i : s)
        os << i << ' ';
    return os;
}

///////////////////////////////////////////////////////////////////////
int main()
{
    #define LOCAL_

    #if defined(LOCAL_)
        ifstream cin("input.txt");
    #endif // defined

    int n, k;
    cin >> n >> k;

    vector<int> c(n);
    for(int &i : c)
        cin >> i;

    priority_queue<int> q;
    for(int i = 0; i < k + 1; ++i)
        q.push(0);

    sort(begin(c), end(c), greater<int>());

    ll ans = 0;
    for(int i = 0; i < n; ++i)
    {
        ll best = q.top();
        q.pop();
        ans += best;
        q.push(c[i] + best);
    }
    cout << ans;
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <immintrin.h>

#include <deque>

constexpr int MAXN = 5e5;

int n, k;
int input[MAXN];
std::deque<int> vec[MAXN], help;

void solve() {
	std::cin >> n >> k;
	for (int i = 0; i < n; i++) {
		std::cin >> input[i];
	}
	std::sort(input, input + n);

	{
		int64_t sum = 0;
		for (int i = n - 1; i >= 0; i--) {
			sum += input[i];
			help.push_back(input[i]);
			if (sum >= 0) {
				;
			} else {
				n = i;
				break;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		if (input[i] < 0) {
			vec[(i + 1) % (k + 1)].push_back(input[i]);
		} else {
			vec[0].push_back(input[i]);
		}
	}
	vec[0].insert(vec[0].end(), help.rbegin(), help.rend());
	int64_t res = 0;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j < vec[i].size(); j++) {
			res += vec[i][j] * 1ll * j;
		}
	}
	std::cout << res << '\n';
}

int32_t main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

	int t = 1;
	//std::cin >> t;
	while (t--) {
		solve();
	}

	std::cout.flush();
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <immintrin.h>

#include <deque>

constexpr int MAXN = 5e5;

int n, k;
int input[MAXN];
std::deque<int> vec[MAXN], help;

void solve() {
	std::cin >> n >> k;
	for (int i = 0; i < n; i++) {
		std::cin >> input[i];
	}
	std::sort(input, input + n);

	{
		int64_t sum = 0;
		for (int i = n - 1; i >= 0; i--) {
			sum += input[i];
			help.push_back(input[i]);
			if (sum >= 0) {
				;
			} else {
				break;
			}
		}
		n = n - help.size();
	}

	for (int i = 0; i < n; i++) {
		if (input[i] < 0) {
			vec[(i + 1) % (k + 1)].push_back(input[i]);
		} else {
			vec[0].push_back(input[i]);
		}
	}
	vec[0].insert(vec[0].end(), help.rbegin(), help.rend());
	int64_t res = 0;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j < vec[i].size(); j++) {
			res += vec[i][j] * 1ll * j;
		}
	}
	std::cout << res << '\n';
}

int32_t main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

	int t = 1;
	//std::cin >> t;
	while (t--) {
		solve();
	}

	std::cout.flush();
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <immintrin.h>

#include <deque>

constexpr int MAXN = 5e5 + 5;

int n, k;
int input[MAXN];
std::deque<int> vec[MAXN], help;

void solve() {
	std::cin >> n >> k;
	for (int i = 0; i < n; i++) {
		std::cin >> input[i];
	}
	std::sort(input, input + n);

	{
		int64_t sum = 0;
		for (int i = n - 1; i >= 0; i--) {
			sum += input[i];
			help.push_back(input[i]);
			if (sum >= 0) {
				;
			} else {
				help.pop_back();
				break;
			}
		}
		n = n - help.size();
	}

	for (int i = 0; i < n; i++) {
		if (input[i] < 0) {
			vec[(i + 0) % (k + 1)].push_back(input[i]);
		} else {
			vec[0].push_back(input[i]);
		}
	}
	vec[0].insert(vec[0].end(), help.rbegin(), help.rend());
	int64_t res = 0;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j < vec[i].size(); j++) {
			res += vec[i][j] * 1ll * j;
		}
	}
	std::cout << res << '\n';
}

int32_t main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

	int t = 1;
	//std::cin >> t;
	while (t--) {
		solve();
	}

	std::cout.flush();
	return 0;
}


            #include<bits/stdc++.h>
            using namespace std;
            int main(){

                int x , y;
                cin >> x >> y;
            while(y!=1){
                if((abs(x-y)+1)%2 == 0 && x >= (y-1) && y!=0){
                    cout << "Yes" << endl;

                }else{

                    cout << "No" << endl;

                }

            }
            if(y == 1 && x == 0){
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }


#include <iostream>
#include <algorithm>
using namespace std;
long long n, m;

void recursion(int copy,int original) {
	if (copy == n && original == m) {
		cout << "Yes" << endl;
		exit(0);
	}
	else if (copy > n || original > m) {
		return;
	}

	recursion(copy +1, original +1);
	recursion(copy +2, original);

}

int main() {
	cin >> n >> m;
	recursion(0,1);
	cout << "No" << endl;
	return 0;
}


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

typedef long long int LL;
typedef unsigned long long uLL;
typedef pair< int,int > ii;
typedef pair< int,ii > iii;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 100005;
const int MOD = 1e9+7;
const double EPS = 1e-6;
const double PI = acos(-1.0);
#define endl        '\n'
#define F           first
#define S           second
#define pb          push_back
#define mp          pake_pair
#define CLR(V)      V.clear()
#define SORT(V)     sort( V.begin(), V.end() )
#define REV(V)      sort( V.rbegin(), V.rend() )
#define MEM(a,x)    memset( a, x, sizeof(a) )
#define FOR(i,a,b)  for( int i = a; i <= b; i++ )
#define ROF(i,a,b)  for( int i = b; i >= a; i-- )
#define REP(i,a)    for( int i = 0; i < a; i++ )
#define debug(x)    cerr << "The value is "<< x << endl
#define Unique(a)   sort( all(a)), a.erase( unique( all(a) ), a.end() )
#define UB(a,key)   upper_bound( a.begin(), a.end(), key )-a.begin()
#define LB(a,key)   lower_bound( a.begin(), a.end(), key )-a.begin()

LL ori , cop;

void solve( LL x , LL y ) {
    //cout << x << " " << y << endl;
    if( x > ori || y > cop ) return;
    if( x == ori && y == cop ) {
        puts("Yes");
        exit(0);
    }
    solve( x+1 , y+1 );
    if( y >= 1 ) solve( x , y+2 );
}
int main( int argc, char const *argv[] ) {
    scanf("%lld %lld",&cop,&ori);
    if( ori == 0 ) {
        puts("No");
        return 0;
    }
    LL x = 1 , y = 0; //or , cop
    solve( x , y );
    puts("No");
    return 0;
}


#include <cstdio>
#include <cstdlib>

int x, y;
void f(int a, int b)
{
    if(a>x||b>y) return;
    if(a==x&&b==y)
    {
        printf("Yes");
        exit(0);
    }
    f(a+1, b+1);
    if(a>0) f(a+2, b);
}
int main() {
    scanf("%d%d", &x, &y);
    f(0,1);
    printf("No");
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)

int n, m, mll[5][5], md = 1e9 + 7;
vector<int> v[500];
char in[501];

inline void sb(int &x, int y) { if ((x -= y) < 0)x += 5; }

inline void ml(vector<int> &a, vector<int> &b, int bg){
	int d = 0;
	f(i, 1, 5)if (mll[a[bg]][i] == b[bg]) { d = i; break; }
	f(i, bg, m)sb(b[i], mll[d][a[i]]);
}

int main(){
	f(i, 0, 5)f(j, 0, 5)mll[i][j] = i * j % 5;
	scanf("%d%d", &n, &m);
	f(i, 0, n){
		scanf("%s", in);
		v[i].resize(m);
		f(j, 0, m)v[i][j] = in[j] - 'a';
	}
	int w = 0;
	f(i, 0, m){
		int k = -1;
		f(j, w, n)if (v[j][i]) { k = j; break; }
		if (k == -1)continue;
		swap(v[w], v[k]);
		++w;
		f(j, w, n)if (v[j][i])ml(v[w - 1], v[j], w);
	}
	int q;
	scanf("%d", &q);
	while (q--){
		scanf("%s", in);
		vector<int> z(m);
		f(i, 0, m)z[i] = in[i] - 'a';
		int an = 1, w = 0;
		f(i, 0, n){
			while (w < m && v[i][w] == 0){
				if (z[w] != 0) { an = 0; break; }
				++w;
			}
			if (an == 0)break;
			if (w == m)an = (ll)an * 5 % md;
			else {
				if (z[w] != 0)ml(v[i], z, w);
				++w;
			}
		}
		printf("%d\n", an);
	}
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

typedef vector<int> ROW;
typedef vector<ROW> MATRIX;
int iv[5];

void gauss(MATRIX& a) {
    int i, j, k, n = a.size(), m = a[0].size();
    for (i = 0; i < n; i++) {
        if (!a[i][i]) {
            for (j = i + 1; j < n; j++) {
                if (a[j][i]) {
                    for (k = 0; k < m; k++) {
                        a[i][k] += a[j][k];
                        if (a[i][k] >= 5) {
                            a[i][k] -= 5;
                        }
                    }
                    break;
                }
            }
        }
        if (!a[i][i]) continue;
        int t = a[i][i];
        for (k = 0; k < m; k++) a[i][k] = mult(a[i][k], iv[t], 5);
        for (j = 0; j < n; j++) {
            if (j == i) continue;
            t = a[j][i];
            for (k = 0; k < m; k++) {
                a[j][k] -= a[i][k] * t % 5;
                if (a[j][k] < 0) {
                    a[j][k] += 5;
                }
            }
        }
    }
}

const int maxn = 1000 + 5;
int n, m, q;
int a[maxn][maxn];
int b[maxn][maxn];

void solve() {
    FOR(i, 1, 5) iv[i] = inv(i, 5);
    cin >> n >> m;
    FOR(i, 0, n) {
        string s; cin >> s;
        FOR(j, 0, m) a[j][i] = s[j] - 'a';
    }
    cin >> q;
    FOR(i, 0, q) {
        string s; cin >> s;
        FOR(j, 0, m) b[i][j] = s[j] - 'a';
    }
    MATRIX mat(m, ROW(n + q));
    FOR(i, 0, m) {
        FOR(j, 0, n) mat[i][j] = a[i][j];
        FOR(j, 0, q) mat[i][n + j] = b[j][i];
    }
    gauss(mat);
    FOR(k, 0, q) {
        int found = 0, rk = 0;
        FOR(i, 0, m) {
            int tot = 0;
            FOR(j, 0, n) tot += mat[i][j];
            if (!tot && mat[i][n + k]) {
                found = 1;
                break;
            }
            if (tot) rk++;
        }
        if (found) {
            cout << 0 << "\n";
            continue;
        }
        cout << fpow(5, n - rk) << "\n";
    }
}

int main() {
    int JUDGE_ONLINE = 1;
    if (fopen("in.txt", "r")) {
        JUDGE_ONLINE = 0;
        assert(freopen("in.txt", "r", stdin));
        //assert(freopen("out.txt", "w", stdout));
    }
    else {
        ios_base::sync_with_stdio(0), cin.tie(0);
    }
    solve();
    if (!JUDGE_ONLINE) {
        //cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    }
    return 0;
}


#include<stdint.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define VIS(it,con) for(auto it=con.begin();it!=con.end();++it)
#define pob pop_back
#define pf push_front
#define pof pop_front
#define MIN(x,y) (x=min(x,(y)))
#define MAX(x,y) (x=max(x,(y)))
#define mid (l+r>>1)
#define lch (idx*2+1)
#define rch (idx*2+2)
/*****************************************************************************/
#include<bits/stdc++.h>
#define int int_fast64_t
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> VI;
#define REP(i,j,k) for(register int i=(j);i<(k);++i)
#define RREP(i,j,k) for(register int i=(j)-1;i>=(k);--i)
#define ALL(a) a.begin(),a.end()
#define MST(a,v) memset(a,(v),sizeof a)
#define pb push_back
#define F first
#define S second
#define endl '\n'
//																#define __debug
#ifdef __debug
	#define IOS (void)0
	#define de(...) cerr<<__VA_ARGS__
	#define ar(a,s,t) {REP(__i,s,t)de(a[__i]<<' ');de(endl);}
#else
	#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)
	#define de(...) (void)0
	#define ar(...) (void)0
#endif
/***********************************default***********************************/
const int maxn=509,maxq=309,mo=1e9L+7;
const int inv[5]={0,1,3,2,4};
const double eps=1e-8;
int n,m,q,res=1,ok[maxq],a[maxn][maxn+maxq];

void sol(){
	REP(i,0,n){
		int bst=-1;
		REP(j,i,m)if(bst<0||a[j][i]>a[bst][i])bst=j;
		swap(a[bst],a[i]);
		if(a[i][i]==0)continue;
		RREP(j,n+q,i)a[i][j]=a[i][j]*inv[a[i][i]]%5;
		REP(j,0,m)if(i!=j)RREP(k,n+q,i)a[j][k]=(a[j][k]+5-a[i][k]*a[j][i]*inv[a[i][i]]%5)%5;
	}
	fill(ok,ok+q,1);
	REP(i,0,n){
		if(a[i][i]==0){
			res=res*5%mo;
			REP(j,0,q)if(a[i][n+j]!=0)ok[j]=0;
		}
	}
	REP(i,n,m)REP(j,0,q)if(a[i][n+j]!=0)ok[j]=0;
}

main(){
	IOS;
	cin>>n>>m;
	MST(a,0);
	REP(i,0,n)REP(j,0,m){
		char c;cin>>c;
		a[j][i]=c-'a';
	}
	cin>>q;
	REP(i,0,q)REP(j,0,m){
		char c;cin>>c;
		a[j][n+i]=c-'a';
	}
	sol();
	REP(i,0,q)cout<<(ok[i]?res:0)<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &(x))
#define F first
#define S second
#define ll long long
const int N = 505;
int mod = 5;
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
    int x = 1 % mod;
    while(b){
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
int _inv[5] = {0, 1, 3, 2, 4};
inline int inv(int a){ return powr(a, mod - 2);}
vector<pair<int, pair<int, int> > > transforms;
vector<int> zero_rows;
int FREE = 0;
struct matrix{
    int M[N][N], n, m;
    matrix(){}
    matrix(int _n, int _m){n = _n, m = _m;}
    void print(){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++) cerr << M[i][j] << " ";
            cerr << endl;
        } cerr << endl;
    }
    void rre(){
        for(int j = 0; j < m; j++){
                int f = 1;
            for(int i = 0; i < n; i++){
                if(M[i][j]){
                    f = 0;
                    int INV = _inv[M[i][j]];
                    for(int k = 0; k < n; k++){
                        if(k != i){
                            // M[k] -= M[i] * (M[k][j]/M[i][j])
                            int p = mul(M[k][j], INV);
                            for(int _j = 0; _j < m; _j++) M[k][_j] = sub(M[k][_j], mul(p, M[i][_j]));
                            transforms.push_back({i, {k, p}});
                        }
                    }
                }
            }
                if(f) FREE++;
        }
        for(int i = 0; i < n; i++){
            bool f = 1;
            for(int j = 0; j < m; j++) if(M[i][j]) f = 0;
            if(f) zero_rows.push_back(i);
        }
    }
} ;
char str[505];
int b[N], powers[505];
int main(){
    mod = 1e9 + 7;
    int n, m, q;
    sd(n); sd(m);
    matrix mat = matrix(m, n);
    for(int i= 0; i < n; i++){
        scanf("%s", str);
        for(int j = 0; j < m; j++){
            mat.M[j][i] = str[j] - 'a';
        }
    }
    // mat.print();
    mat.rre();
    // mat.print();
    sd(q);
    while(q--){
        scanf("%s", str);
        for(int i = 0; i < m; i++) b[i] = str[i] - 'a';
        for(auto it : transforms){
            int i = it.F, k = it.S.F, p = it.S.S;
            b[k] = sub(b[k], mul(p, b[i]));
        }
        bool f = 0;
        for(int i : zero_rows) if(b[i]) f = 1;
        if(f){
            printf("%d\n", 0);
            continue;
        }
        mod = 1e9 + 7;
        int ans = 1;
        for(int i = 0; i < n - (m - zero_rows.size()); i++) ans = mul(ans, 5);
        printf("%d\n", ans);
        mod = 5;
    }
}


#include <iostream>

using namespace std;

int main()
{
   int x,y,z,a=0,b=0,c=0;
    cin>>x>>y;
    if(x==y)
        cout<<y<<endl;
    if(x>100)
        cout<<2<<endl;
    z=y-x+1;
   ;

    int  k[z];
    for( int i=0;i<z;i++){
        k[i]=x;
        x++;
        if(k[i]%2==0)
            a+=1;
        else if (k[i]%3 ==0)
            b+=1;
        else if (k[i]%5 ==0)
            c+=1;

    }
    if (a>b&&a>c)
        cout<<2<<endl;
    else if (b>a&&b>c)
        cout<<3<<endl;
    else if (c>a&&c>b)
    cout<<5<<endl;
    else if(a==b&&b==c)
        cout<<2<<endl;
    else if (a==c)
    cout<<2<<endl;
    else if (a==b)
        cout<<2<<endl;

    return 0;
    }


#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>
#include <utility>
#include <vector>
using namespace std;
int main()
{
    vector<int> vec;
	int l, r;
	cin >> l >> r;
	for (int i = l; i <= r; i++)
	{
		vec.push_back(i);
	}
	int arr[10000];
	int x;
	for (int i = 0; i < 10000; i++)
		arr[i] = 0;
	for (int i = 0 ; i < vec.size(); i++)
	{
		x = vec[i];
		for (int j = 2; j < x / 2; j++)
		{
			if (x % j == 0)
				arr[j]++;
		}
	}
	int c = arr[0];
	int index = 0;
	for (int i = 1; i < 10000; i++)
	{
		if (arr[i] > c)
		{
			c = arr[i];
			index = i;
		}
	}
	cout << index << endl;
	return 0;
}


#include<iostream>
using namespace std;
int l,r,i,j,dp[100000000],ans;
main(){
       cin>>l>>r;
       for(i=l;i<=r;i++)
        for(j=2;j<=r-l;j++){
         if(i%j==0)dp[j]++;
        }
       for(i=2;i<=r-l;i++)
        ans=max(dp[i],ans);
       for(i=2;i<=r-l;i++)
        if(dp[i]==ans){
         cout<<i;return 0;
        }
}


#include <stdio.h>
#include<iostream>
#include <conio.h>
#include <Math.h>
//#include <string.h>

using namespace std;

int main()
{
    string a, t, s;
    a = "qwertyuiopasdfghjkl;zxcvbnm,./";
    char x;
    int y;
    cin >> x;
    s = "";
    if (x == 'R')
    {
         y = -1;
    }
    if (x == 'L')
    {
         y = 1;
    }
    cin >> t;
    int len = t.size();
    for (int j = 0; j < len ; j++)
    {
        for (int i = 0; i<30; i++)
        {
        if (t[j] == a[i])
        {
           s = s + a[i + y];
        }
        }
    }
 //   for (int j = 0; j<sizeof(s); j++)
//    {
       cout << s;
 //   }
getch();
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
#define N 40050
#define eps 1e-8
double n,m;long long ans;
int main()
 {
    cin >>n>>m;m+=1;n+=1;int t=n-m;
    for (int i=m,l=2-n-i;i<=t;i++)
     for (int j=i;j<=t;j++)
      {
         double k=(i-2*n-j)/4,e=(k*k*2+n*(2*i+j-2*n)-i*j)/2;
         if (e<=0) continue;e=sqrt(e);
         double q=int(-e-k+1),w=int(e-k-eps);
         ans+=(w-q+1)*(1+(i!=j));
      }
    cout <<ans*3<<endl;
    return 0;
 }


#include<cstdio>
#define LL long long
int n,m;
int main()
{
	LL ans,sum;
	int b,c,A,B,C,D,E,l;
	scanf("%d%d",&n,&m);
	n++; m++; ans=0;
	for (c=m;c<=n>>1;c++)
	{
		C=((n*n-n*c+c*c)<<1)+(n-m)*(n+c);
		A=(n<<1)-c; D=n-m; E=n+c; sum=0;
		for (b=n-m;b>=m;b--)
		{
			l=C/(A-b);
			if (m>l) l=m-1;
			if (l>=D) break;
			sum+=D-l; C-=E;
		}
		if (c<<1<n) ans+=sum<<1;
		else ans+=sum;
	}
	printf("%I64d\n",ans*3); return 0;
}


#include<algorithm>
#include<cassert>
#include<complex>
#include<map>
#include<iomanip>
#include<sstream>
#include<queue>
#include<set>
#include<string>
#include<vector>
#include<iostream>
#include<cstring>
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define fup FOR
#define fdo FORD
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define siz SZ
#define CLR(x) memset((x), 0, sizeof(x))
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define FI X
#define SE Y
#define SQR(a) ((a)*(a))
#define DEBUG 1
#define debug(x) {if (DEBUG)cerr <<#x <<" = " <<x <<endl; }
#define debugv(x) {if (DEBUG) {cerr <<#x <<" = "; FORE(it, (x)) cerr <<*it <<", "; cout <<endl; }}
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int>P;
typedef vector<int>VI;
const int INF=1E9+7;
template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
#define MAXN 100007

int n,m;
LL res;

int main(){
	ios_base::sync_with_stdio(false);
    cout << setprecision(9) << fixed;
	//in
    cin >> n >> m;
	//sol
    FOR(i,1+m,n-m) {
        int a = 2*i*i-i*m-2*i*(n+1)+m*(n+1);
        FOR(j,1+m,n-m) {
        a += n+1-i;
        int b = (-a+i+j-1) / (i+j);
        if(b < m+1) continue;
        if(b >= n-m+2) {
            res += (LL)(n-m-j+1) * (n-2*m);
            break;
        }
        res += b - (m + 1);
    }
    }
	//out
    cout << 3*res << endl;
	return 0;
}


#include <algorithm>

#include <stdio.h>

#include <memory.h>

#include <string.h>

#include <ctype.h>

#include <cmath>

#include <ctime>

#include <queue>

#include <vector>

#include <string>

#include <set>

#include <map>

#include <bitset>

using namespace std;

typedef long long INT;

typedef pair<int, int> pii;

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template <class T> inline void chkmin(T &a, T b) { if (a>b) a=b; }

template <class T> inline void chkmax(T &a, T b) { if (a<b) a=b; }

int res[33333];

int main() {

	int n, m;

	int lg=m+1, rg=n-m;

	INT ans=0;

	scanf("%d%d", &n, &m);

	for (int b=lg; b<=rg; b++) {

		int bb=n+1-b;

		if (bb<b) res[b]=res[bb];

		else {

			int cur=0;

			int u=3*b*bb-1;

			int lc=lg+bb, rc=rg+bb;

			int la=lg+b, ra=rg+b;

			int st=u/rc-3;

			if (st>la) {

				cur+=(st-la)*(rc-lc+1);

				la=st;

			}

			for (int a=la;a<=ra;a++) {

				int mx=u/a;

				if (mx>=rc) cur+=rc-lc+1;

				else if (mx>=lc) cur+=mx-lc+1;

				else break;

			}

			res[b]=cur;

		}

		ans+=res[b];

	}

	printf("%I64d\n", 3*ans);

	return 0;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 10;
const ll mod = 998244353;
const double eps=1e-8;
const double pi = acos(-1);
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
    while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
inline void pt(ll x,ll y){
    if(y==1) printf("%lld ",x);
    else printf("%lld\n",x);
}
ll n,m,tot;
ll sum[N],ans[N];
ll cnt[N<<1+5];
void init(){
    for(int i=1;i<=(N);i++) {
        for (int j = i; j <= (N); j += i) {
            cnt[j]++;
        }
    }
}
int main() {
//    freopen("../in.in", "r", stdin);
//    ios::sync_with_stdio(false);
//    cin.tie(0);cout.tie(0);
    int _;
    init();
    n = read();
    sum[0]=0;

    for(int i=1;i<=n;i++){
        ans[i]=(sum[i-1]+cnt[i])%mod;
        sum[i]=(sum[i-1]+ans[i])%mod;
    }
    pt(ans[n],2);
    return 0;
}


#include<cstdio>
#include<iostream>
#include<cmath>
#define ll long long
#define mod 998244353
#define maxn 100000005
using namespace std;
int n;
ll f[1000005];
int isp[maxn];
int p[maxn],cnt;
void init(){
	isp[1]=1;
	for(int i=2;i<=100000000;i++){
		if(!isp[i]) p[++cnt]=i;
		for(int j=1;j<=cnt&&i*p[j]<=100000000;j++){
			isp[i*p[j]]=1;
			if(i%p[j]==0) break;
		}
	}
}
ll dfs(int x){
	if(x%2) return 0;
	if(!x) return 1;
	if(f[x]) return f[x];
	ll ans=0;
	for(int i=x;i>=1;i--){
		if(2*i-2<x) break;
		ans+=dfs(x-2*(x-i+1));
		ans%=mod;
	}
	/*for(int i=2;i<=x;i++){
		if(2*i-2==x) break;
		if(x%(2*i-2)==0) ans++;
	}*/
	ll tmp=x,i=1,ans1=1,num=0;
	while(tmp>1){
		while(tmp%p[i]==0){
			num++;
			tmp/=p[i];
		}
		if(i!=1) num++;
		ans1*=num;
		ans1%=mod;
		i++;num=0;
	}
	ans+=ans1-1;
	ans%=mod;
	return f[x]=ans;
}
int main(){
	init();
	scanf("%d",&n);
	printf("%lld",dfs(2*n));
	return 0;
}


#include<bits/stdc++.h>
#include<math.h>
#define int long long
using namespace std;
int d[100000007];
	int mod=998244353;
void div(int n)
{
	for(int i=2;i<=n;i++)
	{
		for(int j=i;j<=n;j+=i)
		{
		d[j]++;
		d[j]%=mod;
	}
	}
}
signed main()
{

	int n;
	cin>>n;
	int a[n+1];
	a[0]=0;
	a[1]=1;
	div(n);
	int s=1;
	for(int i=2;i<=n;i++)
	{
		a[i]=s+d[i]+1;
		a[i]%=mod;
		s=s+a[i];
		s%=mod;
	}
	cout<<a[n];
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using lli = long long;
const lli mod = 998244353, N = 1e6 + 3;
lli dp[N];
lli n;
void SieveOfEratosthenes(int n, bool prime[],
                         bool primesquare[], int a[])
{

    //For more details check out: https://www.geeksforgeeks.org/sieve-of-eratosthenes/

    // Create a boolean array "prime[0..n]" and
    // initialize all entries it as true. A value
    // in prime[i] will finally be false if i is
    // Not a prime, else true.
    for (int i = 2; i <= n; i++)
        prime[i] = true;

    // Create a boolean array "primesquare[0..n*n+1]"
    // and initialize all entries it as false. A value
    // in squareprime[i] will finally be true if i is
    // square of prime, else false.
    for (int i = 0; i <= (n * n + 1); i++)
        primesquare[i] = false;

    // 1 is not a prime number
    prime[1] = false;

    for (int p = 2; p * p <= n; p++)
    {
        // If prime[p] is not changed, then
        // it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p starting from p * p
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }

    int j = 0;
    for (int p = 2; p <= n; p++)
    {
        if (prime[p])
        {
            // Storing primes in an array
            a[j] = p;

            // Update value in primesquare[p*p],
            // if p is prime.
            primesquare[p * p] = true;
            j++;
        }
    }
}

// Function to count divisors
int countDivisors(int n)
{
    // If number is 1, then it will have only 1
    // as a factor. So, total factors will be 1.
    if (n == 1)
        return 1;

    bool prime[n + 1], primesquare[n * n + 1];

    int a[n]; // for storing primes upto n

    // Calling SieveOfEratosthenes to store prime
    // factors of n and to store square of prime
    // factors of n
    SieveOfEratosthenes(n, prime, primesquare, a);

    // ans will contain total number of distinct
    // divisors
    int ans = 1;

    // Loop for counting factors of n
    for (int i = 0;; i++)
    {
        // a[i] is not less than cube root n
        if (a[i] * a[i] * a[i] > n)
            break;

        // Calculating power of a[i] in n.
        int cnt = 1;          // cnt is power of prime a[i] in n.
        while (n % a[i] == 0) // if a[i] is a factor of n
        {
            n = n / a[i];
            cnt = cnt + 1; // incrementing power
        }

        // Calculating the number of divisors
        // If n = a^p * b^q then total divisors of n
        // are (p+1)*(q+1)
        ans = ans * cnt;
    }

    // if a[i] is greater than cube root of n

    // First case
    if (prime[n])
        ans = ans * 2;

    // Second case
    else if (primesquare[n])
        ans = ans * 3;

    // Third case
    else if (n != 1)
        ans = ans * 4;

    return ans - 1; // Total divisors
}
lli rec(lli level)
{
    if (level <= 1)
        return 1;
    if (dp[level] != -1)
        return dp[level] % mod;
    lli ans = countDivisors(level) % mod;
    for (lli i = 0; i < level; i++)
        ans = ((ans % mod) + (rec(i) % mod)) % mod;
    //cout << level << '=' << ans << '\n';
    return dp[level] = ans % mod;
}
void solve()
{
    cin >> n;
    memset(dp, -1, sizeof(dp));
    lli ans = rec(n) % mod;
    cout << ans << '\n';
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli _t = 1;
    //cin>>_t;
    while (_t--)
        solve();
    return 0;
}
//Think twice, code once.


#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <chrono>
#include <map>
#include <random>
#include <unordered_map>
#include <iterator>
#include <fstream>
#include <numeric>
#include <functional>
#include <exception>
#include <set>
#include <queue>
#include <string_view>
#include <stack>

#ifdef _WIN32
#include <intrin.h>
#endif // _WIN32

using ll = long long;

ll buildin_one_count(ll number)
{
#ifdef _WIN32
    return __popcnt64(number);
#else
    return __builtin_popcountl(number);
#endif // _WIN32
}

template <class Container>
ll lsize(const Container& container)
{
    return static_cast<ll>(size(container));
}

#define for_n(x) for (ll i = 0; i < x; ++i)

using namespace std;

using position = pair<ll, ll>;
const position zero_point = { 0,0 };

namespace range_ns
{
    template<class Container>
    void print(const Container& container, const char* sep = "\n")
    {
	std::copy(container.begin(), container.end(), ostream_iterator<typename Container::value_type>(cout, sep));
    }

    template<class Container>
    void sort(Container& container)
    {
	std::sort(container.begin(), container.end());
    }

    template<class Container, class T>
    decltype(auto) find(const Container& container, const T& elem)
    {
	return std::find(container.begin(), container.end(), elem);
    }

    template<class Container, class Condition>
    decltype(auto) find_if(const Container& container, Condition condition)
    {
	return std::find_if(container.begin(), container.end(), condition);
    }

    template<class Container, class Condition = std::less<ll>>
    decltype(auto) max_element(Container& container, Condition condition = Condition())
    {
	return std::max_element(container.begin(), container.end(), condition);
    }

    template<class Container, class Condition = std::less<ll>>
    decltype(auto) min_element(const Container& container, Condition condition = Condition())
    {
	return std::min_element(container.begin(), container.end(), condition);
    }

    template<class Container, class Condition = std::less<ll>>
    decltype(auto) minmax_element(const Container& container, Condition condition = Condition())
    {
	return std::minmax_element(container.begin(), container.end(), condition);
    }

    template<class Container, class Condition>
    decltype(auto) any_of(const Container& container, Condition condition)
    {
	return std::any_of(container.begin(), container.end(), condition);
    }

    template<class Container, class Condition>
    decltype(auto) all_of(const Container& container, Condition condition)
    {
	return std::all_of(container.begin(), container.end(), condition);
    }

    template<class Container, class T>
    decltype(auto) count(const Container& container, const T& elem)
    {
	return std::count(container.begin(), container.end(), elem);
    }

    template<class Container, class Condition>
    decltype(auto) count_if(const Container& container, Condition condition)
    {
	return std::count_if(container.begin(), container.end(), condition);
    }

    template<class Container, class Func>
    decltype(auto) for_each(Container& container, Func func)
    {
	return std::for_each(container.begin(), container.end(), func);
    }

    template<class Container, class T>
    decltype(auto) equal_range(const Container& container, const T& elem)
    {
	return std::equal_range(container.begin(), container.end(), elem);
    }

    template<class Container, class T>
    decltype(auto) lower_bound(const Container& container, const T& elem)
    {
	return std::lower_bound(container.begin(), container.end(), elem);
    }

    template<class Container, class T>
    decltype(auto) upper_bound(const Container& container, const T& elem)
    {
	return std::upper_bound(container.begin(), container.end(), elem);
    }

    vector<ll> iota(ll number)
    {
	vector<ll> vec(number);
	std::iota(vec.begin(), vec.end(), 1);
	return vec;
    }

    template<class Container, class Condition>
    void erase_remove_if(Container& container, Condition condition)
    {
	container.erase(remove_if(container.begin(), container.end(), condition), container.end());
    }

    template<class Container, class Condition>
    Container copy_if(const Container& container, Condition condition)
    {
	Container container_result;
	copy_if(container.begin(), container.end(), back_inserter(container_result), condition);
	return container_result;
    }

    template <class Container>
    void reverse(Container& container)
    {
	std::reverse(begin(container), end(container));
    }

    struct sum_functor
    {
	ll operator()(ll sum, ll value) const { return sum + value; }
    };

    template<class Container, class Func = sum_functor>
    ll reduce(const Container& container, ll init_value = 0, Func func = sum_functor())
    {
	return std::accumulate(container.begin(), container.end(), init_value, func);
    }

    template<class Container, class Func = std::equal_to<typename Container::value_type>>
    decltype(auto) adjacent_find(const Container& container, Func func = Func())
    {
	return std::adjacent_find(container.begin(), container.end(), func);
    }

    template<class Container, class Predicate>
    vector<ll> copy_indexes(const Container& container, Predicate predicate)
    {
	vector<ll> indexes;
	for_n(lsize(container))
	    if (predicate(container[i]))
		indexes.push_back(i);

	return indexes;
    }
}

template <class T>
decltype(auto) read_vector(ll n)
{
    vector<T> res(n);
    for (auto& i : res)
	cin >> i;
    return res;
}

using Graph = vector<vector<ll>>;

void debth_first_search(const Graph& graph, ll start_vertex, ll end_vertex)
{
    stack<ll> vertex_stack;
    vertex_stack.push(start_vertex);
    vector<bool> visited(size(graph), false);
    visited[start_vertex] = true;

    vector<ll> path(size(graph), -1);
    while (!vertex_stack.empty())
    {
	ll vertex = vertex_stack.top();
	vertex_stack.pop();

	for (ll v : graph[vertex])
	    if (!visited[v])
	    {
		visited[v] = true;
		vertex_stack.push(v);
		path[v] = vertex;
	    }
    }

    vector<ll> path_end_start = { end_vertex };
    ll vertex = -1;
    while (vertex != start_vertex)
    {
	vertex = path[path_end_start.back()];
	path_end_start.push_back(vertex);
    }

    range_ns::reverse(path_end_start);
    range_ns::for_each(path_end_start, [](ll& v) { ++v; });
    range_ns::print(path_end_start, " ");
}

using factorization_map = unordered_map<ll, ll>;

factorization_map factorize(ll n)
{
    factorization_map ans;

    while (n % 2 == 0)
    {
	++ans[2];
	n = n / 2;
    }

    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
	while (n % i == 0)
	{
	    ++ans[i];
	    n = n / i;
	}
    }

    // n is prime
    if (n > 2)
	++ans[n - 1];

    return ans;
};

using namespace range_ns;

template <class Condition>
ll binary_search(ll l, ll r, Condition condition)
{
    while (l <= r)
    {
	ll m = (l + r) / 2;
	if (condition(m))
	    r = m - 1;
	else
	    l = m + 1;
    }

    return l;
}

vector<int> z_function(string_view s) {
    int n = (int)s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
	if (i <= r)
	    z[i] = min(r - i + 1, z[i - l]);
	while (i + z[i] < n && s[z[i]] == s[i + z[i]])
	    ++z[i];
	if (i + z[i] - 1 > r)
	    l = i, r = i + z[i] - 1;
    }
    return z;
}

int find_fisrt_occurance(const string& t, const string& p)
{
    auto vec = z_function(p + "#" + t);
    for (int i = 0; i < lsize(t); ++i)
	if (vec[i + lsize(p) + 1] == lsize(p))
	    return i;

    return -1;
}

int main(int argc, char** argv)
{
    ll n;
    cin >> n;
    auto vec = read_vector<ll>(n);

    if (size(vec) == 1)
    {
	cout << 0;
	return 0;
    }

    ll ans_start = 0, ans_end = 0, ans_mdiddle = -2, i = 0;
    if (vec[i] == 1)
	while (i < n - 1 && vec[i + 1] == vec[i + 1])
	    ++ans_start;

    i = n - 1;
    if (vec[i] == 1000)
	while (i > 0 && vec[i - 1] == vec[i] - 1)
	    ++ans_end;

    vec.erase(begin(vec));
    vec.erase(end(vec));
    for (ll j = 0; j < lsize(vec); ++j)
    {
	ll curr = 1;
	while (j < lsize(vec) - 1 && vec[j + 1] == vec[j + 1])
	    ++curr;
	ans_mdiddle = max(ans_mdiddle, curr);
    }

    cout << max(max(ans_start, ans_end), ans_mdiddle);
    return 0;
}


#include <iostream>

using namespace std;

int a[105];

int main()
{
    int n;
    cin >> n;
    for(int i = 1; i < n; i++)
        cin >> a[i];
    a[0] = 0;
    a[n + 1] = 1001;
    n += 2;

    int maxl = 0;
    int i = 0;
    while(i < n)
    {
        int l = 1;
        while(i + 1 < n && a[i] + 1 == a[i + 1])
        {
            l++;
            i++;
        }
        if(l > maxl)
            maxl = l;
    }

    cout << maxl - 2 << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i=0,j=0,l,anik[100009]={0},x=0,count=0,flag=0,heda=0;
    cin>>n;
    while(i<n)
    {
        scanf("%d",&anik[i]);

    }
      i=0;
    while(i<n)
    {
        if(anik[i+1]-anik[i]==1 && (i+1)<n)
        {
            if(i==0&&anik[0]==1)
            {
                count++;
            }
            x=i+1;
            while(1)
            {
                if((anik[x]-anik[x-1])==1)
                {
                    count++;
                    x++;
                    if(x==n)
                    {   count--;
                       if(anik[n-1]==1000)
                       {
                           count++;
                       }
                       if(count>heda)
                       {
                           heda=count;
                           count=0;
                       }
                        i=x;
                        break;
                    }

                }
                else
                {   count--;
                  if(count>heda)
                  {
                      heda=count;
                      count=0;
                  }
                     i=x-1;
                    break;
                }
            }
            flag=1;
        }

    }

    cout<<heda<<endl;
}


/********************************************************************************************************\__
                                                                                |
        author  :   FAHIM SHAHRIAR   ||    email   :    imnirobs15@gmail.com                              ||
        Dept. of CSE, Comilla University , Bangladesh.                                                    ||
                                                                                ||
/********************************************************************************************************/

#include <bits/stdc++.h>
using namespace std;
#define READ(f)         freopen(f, "r", stdin)
#define WRITE(f)        freopen(f, "w", stdout)

#define __              std::ios_base::sync_with_stdio(false); cin.tie(0);
#define ___             cerr << endl << "Execution Time : " << 1 * clock() / CLOCKS_PER_SEC << endl;
#define START           double start_s=clock();
#define STOP            double stop_s=clock();
#define _               cerr << "Time Elapsed : " << (stop_s-start_s)/double(CLOCKS_PER_SEC);

#define mem(x,y)        memset(x,y,sizeof(x))
#define mem0(v)         memset(v,0,sizeof(v))
#define all(v)          (v).begin(),(v).end()
#define arrSort         sort(arr,arr+n)
#define vSort           sort(all(v))
#define maxSort         sort(all(v),greater<int>())
#define rSort           sort(v.rbegin(),v.rend())
#define sqr(x)          ((x)*(x))
#define qube(x)         ((x)*(x)*(x))
#define deci(n)         cout<<fixed<<setprecision(n);
#define find_dist(a,b)  sqrt(sqr(a.first-b.first)+sqr(a.second-b.second))
#define DEBUG(x)        cout << #x << " = " << x << endl

#define       rep( i , a , b )     for( i=a ; i<b ; i++)
#define       rev( i , a , b )     for( i=a ; i>=b ; i--)
#define       repx( i ,a,b, x)     for( i=a ; i<b ; i+=x)

#define TC(T)           int T;cin>>T;while(T--)
#define FTC(T)          int T;cin>>T;for(int TestCase=1;TestCase<=T;TestCase++)
#define CASE_OUT(x)     cout << "Case " << TestCase << ": " << x << endl;

#define ERR             1e-9
#define pi              (2*acos(0))
#define PI              3.141592653589793
#define M               1000000007
#define E               "\n"
#define el              cout << endl
#define e               putchar('\n')
#define space           putchar(' ')
#define bor             |

#define sc              scanf
#define pf              printf
#define scin(x)         sc("%d",&(x))
#define scin2(x,y)      sc("d",&(x),&(y))
#define scin3(x,y,z)    sc("d%d",&(x),&(y),&(z))
#define scln(x)         sc("%lld",&(x))
#define sc              scanf
#define pf              printf
#define gc              getchar
#define pc              putchar
#define check(n,pos)    (n & (1<<(pos)))
#define biton(n,pos)    (n  (1<<(pos)))
#define bitoff(n,pos)   (n & ~(1<<(pos)))
typedef long double LD;
typedef unsigned int UI;
typedef long long int LL;
typedef unsigned long long int ULL;
#define SS              stringstream
#define vi              vector<int>
#define vii             vector< vi >
#define pb              push_back

vi prime,primeFactor;bool flg=true;
bool flag = true;

/**                                     Prime Check        ----------------->     isPrime(n)                                                                           **/         template<typename T>inline bool isPrime(T n){if(n<=1)return false;if(n<=3)return true;if(n%2==0 bor n%3==0)return false;for(int i=5;i*i<=n;i+=6)if(n%i==0||n%(i+2)==0)return false;return true;}
/**                                     Sieve Method       ----------------->     sieve(n)                                                                             **/         template<typename T>inline void sieve(T N){int status[(N>>5)+2];memset(status,0,((N>>5)+2)<<2);for(int i=3;i*i<=N;i+=2)if(!(status[i>>5]&(1<<(i & 31))))for(int j=i*i;j<=N;j+=(i<<1))status[j>>5]|=(1<<(j&31));prime.pb(2);for(int i=3;i<=N;i+=2){if(!(status[i>>5]&(1<<(i&31))))prime.pb(i);if(!(N%i))flg=false;}}
/**                                     Factorization      ----------------->     factorization(n)                                                                     **/         template<typename T>inline void factorization(T N){if(flg){primeFactor.pb(N);return;}int Size=0;int sqrtN=int(sqrt(N));while(N>=1&&Size!=prime.size()&&prime[Size]<=sqrtN){while(N%prime[Size]==0){primeFactor.pb(prime[Size]);N/=prime[Size];}Size++;}if(N>1)primeFactor.pb(N);}
/**                                     GCD                ----------------->     gcd(a,b)                                                                             **/         template<typename T>inline T gcd(T a,T b){while(b)b ^= a ^= b ^= a %= b;return a;}
/**                                     LCM                ----------------->     lcm(a,b)                                                                             **/         template<typename T>inline T lcm(T a, T b){return (a / gcd(a,b)) * b;}
/**                                     Big Mod            ----------------->     bigMod(b,p,m)                                                                        **/         template<typename T>inline T mmul(T a, T b, T m) { T result = 0; a %= m; while (b) { if (b % 2) result = (result + a) % m; a = (a + a) % m; b /= 2; } return result; }template<typename T>inline T bigMod(T a, T b, T m) { T result = 1; a %= m; while (b) { if (b % 2) result = mmul(result, a, m); a = mmul(a, a, m); b /= 2; } return result; }
/**                                     Negative Mod       ----------------->     negMod(-a,b)                                                                         **/         template<typename T>inline T negMod(T n,T m){return (n%m+m)%m;}
/**                                     ((a * b) % m)      ----------------->     big(a,b,m)                                                                           **/         template<typename T>inline T bigMul(T a,T b,T m){if(b==0)return 0;T x=bigMul(a,b>>1,m);x=((x%m)+(x%m))%m;if(b&1)x=(x+(a%m))%m;return x;}
/**                                     String to integer  ----------------->     StoI(string s,int x(any integer))                                                    **/         template<typename T>inline T StoI(string s, T ret){SS ss(s);ss >> ret;return ret;}/// extract words or numbers from a line
/**                                     integer to string  ----------------->     ItoS(n)                                                                              **/         template<typename T>inline string ItoS(T n){SS ss;ss << n; return ss.str();}/// convert a number to string
/**                                     min. of 3 numbers  ----------------->     MIN3(x,y,z)                                                                          **/         template<typename T>inline T MIN3(T x,T y,T z){T Min=y^((x^y)& -(x<y));Min=z^((Min^z)& -(Min<z));return Min;}
/**                                     max. of 3 numbers  ----------------->     MAX3(x,y,z)                                                                          **/         template<typename T>inline T MAX3(T x,T y,T z){T Max=x^((x^y)& -(x<y));Max=Max^((Max^z)& -(Max<z));return Max;}
/**                                     Binary to Decimal  ----------------->     BtoD(x)                                                                              **/         template<typename T>inline T BtoD(T x){T two=1,intn=0;while(x){if(x%10)intn+=two;x/=10;two<<=1;}return intn;}
/**                                     Binary to Dec(ULL) ----------------->     BtoI(string s)                                                                       **/         inline ULL BtoD(string str){ULL intS=0,two=1;int len=str.length();for(int i=len-1;i>=0;i--){if(str.at(i)=='1')intS+=two;two<<=1;}return intS;}
/**                                     Dec to Binary(ULL) ----------------->     DtoB(n) [store it in a string]                                                       **/         inline string DtoB(ULL n) { int count = 0; string s = ""; for (int i = 31; i >= 0; i--) { int k = n >> i; if (k & 1) { count  = 1; s += '1'; } else { if(count  == 1) s += '0'; }} return s; }
/**                                     STL all elements   ----------------->     printStl(v)                                                                          **/         //template<typename T>inline void printStl(T &v){int sz=v.size()-1;int k=0;for(auto i=v.begin();i!=v.end();i++,k++){if(k==sz)cout<<*i<<E;else cout<<*i<<" ";}}
/**                                     intput 1 integer   ----------------->     in(x)                                                                                **/         template<typename T>inline void in(T &x){x=0;bool neg=false;register char c=getchar();while((c<48||c>57)&&c!=EOF&&c!='-')c=getchar();if(c=='-'){neg=true;c=getchar();}while(c>=48&&c<=57){x=(x<<3)+(x<<1)+c-48;c=getchar();}if(neg)x=~(x-1);}
/**                                     intput 2 integer   ----------------->     in2(x,y)                                                                             **/         template<typename T>inline T in2(T &a,T &b){in(a);in(b);}
/**                                     intput 3 integer   ----------------->     in3(x,y,z)                                                                           **/         template<typename T>inline T in3(T &a,T &b,T &c){in(a);in(b);in(c);}
/**                                     print  1 integer   ----------------->     out(x)                                                                               **/         template<typename T>inline void out(T x){char a[21];T i=1,j;if(x<0){putchar('-');x=~(x-1);}if(x==0)putchar('0');while(x){a[i++]=x%10+48;x/=10;}for(j=i-1;j>=1;j--)putchar(a[j]);}
/**                                     Remainder          ----------------->     Rem(string divident,LL divisor)                                                      **/         inline LL Rem(string q,LL r) { LL l = q.size(); LL remainder = 0; for(int i=0; i<l; i++) remainder = ((remainder*10) + (q.at(i)-'0') )% r; }
/**                                     Quotient           ----------------->     quotient(string divident,LL divisor)                                                 **/         inline LL quotient(string num,LL number) { long long l,x = 0,mod=0; l= num.size(); int print_done = 0; for(int i=0; i<l; i++) { mod=(mod*10+num.at(i)-'0'); if(mod<number && !print_done) continue; x = (x * 10) + (mod / number); print_done = 1; mod = mod % number; } return x; }
/**                                     Vowel              ----------------->     isVowel(char c)                                                                      **/         bool isVowel(char ch){ch=toupper(ch);return(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E');return false;}
/**                                     Consonant          ----------------->     isConsonant(char c)                                                                  **/         bool isConsonant(char ch){return(isalpha(ch) && !isVowel(ch));return false;}

vi v1 , v2;
int main()
{
    while(1) {
    __
    int n;
    cin >> n;

    for(int i = 0;i < n;i++) {
        int x;
        cin >> x;
        v1.push_back(x);
    }

    int cnt = 0;
    int maxcnt = 0;
    int L = -1;
    for(int i = n - 1 ; i > 0; i--) {
        if(v1[i] - v1[i - 1] != 1) {
            if(cnt > maxcnt) {
            maxcnt = cnt;
            L = i;
            }
            cnt = 0;
        }
        else {
            cnt++;
            if(i == 1 && v1[0] == 1 && v1[n-1] != n ) {
                    cnt++;
                    if(n  == cnt + 1) cnt--;
            }

        }
    }

    int x;
    x =  max(maxcnt,cnt);
    if(x == 0 ) cout << 0 << endl;
    else if(x ==1 && n == 2) {
        if((v1[0] == 1 && v1[1] == 2) || (v1[0] == 999 && v1[1] == 1000)) cout << 1 << endl;
        else cout << 0 << endl;
    }
    else if(v1[x + L] == 1000) cout << "A" << " ", cout << x << endl;

    else {
    if(x == n - 1) {
        if(v1[0] == 1 || v1[n-1] == 1000)cout << "b" << " ", cout << x << endl;
        else cout << x - 1 << endl;
    }
    else if(v1[1] - v1[0] == 1 && L < 2) {
            if(n - 2 == x) x--;
            cout << x << endl;
    }
    else {
            if(n - 2 == x) x--;
            cout << x - 1 << endl;
    }
    }

v1.clear();
    }
    return 0;
}