#include<bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) ((int)((x).size()))
#define IN(x,y) ((y).find((x)) != (y).end())
#define DBG(v) cerr<<#v<<" = "<<(v)<<endl;
#define FOREACH(i,t) for (typeof(t.begin()) i = t.begin(); i != t.end(); ++i)
#define fi first
#define se second

const int maxn = 2000000;
const int smaxn = 2000;

int sumpr[maxn+2];
bool pr[maxn+2];
bool pal[maxn+2];
int sumpal[maxn+2];

int main() {
	FORI(i,maxn) pr[i]=true;
	pr[1]=false;
	for (int i=2;i*i<maxn;i++) if (pr[i]) for (int j=i*i; j<=maxn; j+=i) pr[j]=false;
	FORI(i,maxn) sumpr[i]=sumpr[i-1]+pr[i];
	FOR(i,smaxn) if (i==0 || i%10) {
		int cur=i, inv=0, base=1;
		while (cur>0) {
			inv = inv*10+(cur%10);
			cur /= 10;
			base *= 10;
		}
		int U = inv*base+i;
		if (U<=maxn) pal[U] = true;
		FOR(d,10) {
			int V = (inv*10+d)*base+i;
			if (V<=maxn) pal[V] = true;
		}
	}
	FORI(i,maxn) sumpal[i]=sumpal[i-1]+pal[i];
	int p,q;
	scanf("%d%d", &p, &q);
	int last=-1;
	FORI(i,maxn) if (1LL*sumpr[i]*q <= 1LL*sumpal[i]*p) last=i;
	if (last==-1) {
		printf("Palindromic tree is better than splay tree\n");
		return 0;
	}
	printf("%d\n", last);
	//FORI(i,100) printf("%d %d -- %.4lf\n", sumpr[i], sumpal[i], 1.0*sumpr[i]/sumpal[i]);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) ((int)((x).size()))
#define IN(x,y) ((y).find((x)) != (y).end())
#define DBG(v) cerr<<#v<<" = "<<(v)<<endl;
#define FOREACH(i,t) for (typeof(t.begin()) i = t.begin(); i != t.end(); ++i)
#define fi first
#define se second

const int maxn = 1000000;
const int smaxn = 1000;

int sumpr[maxn+2];
bool pr[maxn+2];
bool pal[maxn+2];
int sumpal[maxn+2];

int main() {
	FORI(i,maxn) pr[i]=true;
	pr[1]=false;
	for (int i=2;i*i<maxn;i++) if (pr[i]) for (int j=i*i; j<maxn; j+=i) pr[j]=false;
	FORI(i,maxn) sumpr[i]=sumpr[i-1]+pr[i];
	FOR(i,smaxn) if (i==0 || i%10) {
		int cur=i, inv=0, base=1;
		while (cur>0) {
			inv = inv*10+(cur%10);
			cur /= 10;
			base *= 10;
		}
		pal[inv*base+i] = true;
		FOR(d,10) {
			int V = (inv*10+d)*base+i;
			if (V<maxn) pal[V] = true;
		}
	}
	FORI(i,maxn) sumpal[i]=sumpal[i-1]+pal[i];
	int p,q;
	scanf("%d%d", &p, &q);
	int last=-1;
	FORI(i,maxn) if (sumpr[i]*q <= sumpal[i]*p) last=i;
	printf("%d\n", last);
	//FORI(i,40) printf("%d %d\n", sumpr[i], sumpal[i]);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) ((int)((x).size()))
#define IN(x,y) ((y).find((x)) != (y).end())
#define DBG(v) cerr<<#v<<" = "<<(v)<<endl;
#define FOREACH(i,t) for (typeof(t.begin()) i = t.begin(); i != t.end(); ++i)
#define fi first
#define se second

const int maxn = 2000000;
const int smaxn = 2000;

int sumpr[maxn+2];
bool pr[maxn+2];
bool pal[maxn+2];
int sumpal[maxn+2];

int main() {
	FORI(i,maxn) pr[i]=true;
	pr[1]=false;
	for (int i=2;i*i<maxn;i++) if (pr[i]) for (int j=i*i; j<=maxn; j+=i) pr[j]=false;
	FORI(i,maxn) sumpr[i]=sumpr[i-1]+pr[i];
	FOR(i,smaxn) if (i==0 || i%10) {
		int cur=i, inv=0, base=1;
		while (cur>0) {
			inv = inv*10+(cur%10);
			cur /= 10;
			base *= 10;
		}
		int U = inv*base+i;
		if (U<=maxn) pal[U] = true;
		FOR(d,10) {
			int V = (inv*10+d)*base+i;
			if (V<=maxn) pal[V] = true;
		}
	}
	FORI(i,maxn) sumpal[i]=sumpal[i-1]+pal[i];
	int p,q;
	scanf("%d%d", &p, &q);
	int last=-1;
	FORI(i,maxn) if (1LL*sumpr[i]*q <= 1LL*sumpal[i]*p) last=i;
	printf("%d\n", last);
	//FORI(i,100) printf("%d %d -- %.4lf\n", sumpr[i], sumpal[i], 1.0*sumpr[i]/sumpal[i]);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) ((int)((x).size()))
#define IN(x,y) ((y).find((x)) != (y).end())
#define DBG(v) cerr<<#v<<" = "<<(v)<<endl;
#define FOREACH(i,t) for (typeof(t.begin()) i = t.begin(); i != t.end(); ++i)
#define fi first
#define se second

const int maxn = 2000000;
const int smaxn = 2000;

int sumpr[maxn+222];
int pr[maxn+222];
int pal[maxn+222];
int sumpal[maxn+222];

int main() {
	FORI(i,maxn) pr[i]=1;
	pr[1]=0;
	for (int i=2;i*i<maxn;i++) if (pr[i]) for (int j=i*i; j<=maxn; j+=i) pr[j]=0;
	FORI(i,maxn) sumpr[i]=sumpr[i-1]+pr[i];
	FOR(i,smaxn) if (i==0 || i%10) {
		int cur=i, inv=0, base=1;
		while (cur>0) {
			inv = inv*10+(cur%10);
			cur /= 10;
			base *= 10;
		}
		int U = inv*base+i;
		if (U<=maxn) pal[U] = 1;
		FOR(d,10) {
			int V = (inv*10+d)*base+i;
			if (V<=maxn) pal[V] = 1;
		}
	}
	FORI(i,maxn) sumpal[i]=sumpal[i-1]+pal[i];
	int p,q;
	scanf("%d%d", &p, &q);
	int last=-1;
	FORI(i,maxn) if (1LL*sumpr[i]*q <= 1LL*sumpal[i]*p) last=i;
	if (last==-1) {
		printf("Palindromic tree is better than splay tree\n");
		return 0;
	}
	printf("%d\n", last);
	//FORI(i,100) printf("%d %d -- %.4lf\n", sumpr[i], sumpal[i], 1.0*sumpr[i]/sumpal[i]);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) ((int)((x).size()))
#define IN(x,y) ((y).find((x)) != (y).end())
#define DBG(v) cerr<<#v<<" = "<<(v)<<endl;
#define FOREACH(i,t) for (typeof(t.begin()) i = t.begin(); i != t.end(); ++i)
#define fi first
#define se second

const int maxn = 2000000;
const int smaxn = 2000;

int sumpr[maxn+222];
int pr[maxn+222];
int pal[maxn+222];
int sumpal[maxn+222];

int main() {
	FORI(i,maxn) pr[i]=1;
	pr[1]=0;
	for (int i=2;i*i<maxn;i++) if (pr[i]) for (int j=i*i; j<=maxn; j+=i) pr[j]=0;
	FORI(i,maxn) sumpr[i]=sumpr[i-1]+pr[i];
	FOR(i,smaxn) {
		int cur=i, inv=0, base=1;
		while (cur>0) {
			inv = inv*10+(cur%10);
			cur /= 10;
			base *= 10;
		}
		int U = i*base+inv;
		if (U<=maxn) pal[U] = 1;
		FOR(d,10) {
			int V = (i*10+d)*base+inv;
			if (V<=maxn) pal[V] = 1;
		}
	}
	FORI(i,maxn) sumpal[i]=sumpal[i-1]+pal[i];
	//printf("%d %d %d %d %d\n", sumpal[10], sumpal[100], sumpal[1000], sumpal[2000], sumpal[2520]);
	int p,q;
	scanf("%d%d", &p, &q);
	int last=-1;
	FORI(i,maxn) if (1LL*sumpr[i]*q <= 1LL*sumpal[i]*p) last=i;
	if (last==-1) {
		printf("Palindromic tree is better than splay tree\n");
		return 0;
	}
	printf("%d\n", last);
	//for (int i=2450; i<2550; i++) printf("%d -- %d %d -- %.4lf\n", i, sumpr[i], sumpal[i], 1.0*sumpr[i]/sumpal[i]);
	return 0;
}


#include <iostream>
#include <assert.h>
#include <stack>
#include <algorithm>
#include <queue>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <string.h>
#include <string>
#include <stdio.h>
#define sf scanf
#define pf printf
#define ll long long

#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i )
#define pb push_back

using namespace std;

int nima_pi[10000010];
int nima_rd[10000010];

int checkp( int t )
{
    int k = t, m = 0;
    while( k > 0 )
    {
        m = m * 10 + k % 10;
        k/=10;
    }
    return ( t == m );
}

int cnt;
int pr[1000000];
int is[10000010];
void init()
{
    cnt = 0;
    clr( is );
    int num = 10000000;
    for( int i = 2; i < num; ++i )
    {
        if( !is[i] )
        {
            pr[cnt++] = i;
        }
        for( int j = 0; j < cnt && pr[j] * i < num; ++j )
        {
            is[ i * pr[j] ] = 1;
        }
    }
    nima_pi[1] = 0;
    for( int i = 2; i < num; ++i )
    {
        nima_pi[i] = nima_pi[i-1] + (is[i]==0);
    }

    nima_rd[1] = 1;
    for( int i = 2; i < num; ++i )
    {
        nima_rd[i] = nima_rd[i-1] + checkp(i);
    }
   // printf("40 = %d, %d\n",nima_pi[40], nima_rd[40]);
}

int pi( int n )
{
    return nima_pi[n];
}

int rd( int n )
{
    return nima_rd[n];
}

int xt[43][43];

int gcd( int a, int b )
{
    return b?gcd(b,a%b):a;
}

int xtt[43][43];
void solve()
{
    clr( xtt );
    int ret = -1;
    int num = 1000000;
    for( int i = 1; i < num; ++i )
    {
        int p1 = pi( i );
        int p2 = rd( i );

        for( int p = 1; p <=42; ++p )
        {
            int q = (ll)p2 * p /p1;
            xtt[p][q]=i;
        }
    }

    for( int p = 1; p <42; ++p )
    {
        for( int q = 1; q <=42; ++ q )
        {
            for( int qq = q; qq <= 42; ++qq )
            {
                xtt[p][q]= max( xtt[p][qq], xtt[p][q] );
            }

            if( xtt[p][q] != xt[p][q] )
            {
                printf("p = %d q = %d xt = %d xtt = %d\n",p,q,xt[p][q], xtt[p][q]);
            }
        }
    }
}

int main()
{
    _clr( nima_pi );
    _clr( nima_rd);
    _clr( xt );
    init();
    for( int p = 1; p < 43; ++p )
    {
        for( int q = 1; q <43; ++q )
        {
            int x = gcd(p,q);
            int pp = p/x;
            int qq = q/x;
            if( xt[pp][qq] != -1 )
            {
                continue;
            }

            int  num = 10000;

            if( p < 10 ) num = 148360;
            if( p < 20 ) num = 300000;
            if( p < 30 ) num = 600000;
            if( p < 40 ) num = 1000000;
            if( p >= 40 ) num = 1200000;

            int ret = -1;
            for( int i = 1; i < num; ++i )
            {
                int p1 = pi( i );
                int p2 = rd( i );
                if( p1 * qq <= p2 * pp )
                {
                    ret = max( ret, i );
                }
            }
//          printf("p = %d q = %d ret = %d, %d %d\n",pp,qq,ret, pi(ret), rd(ret));
            xt[pp][qq] = ret;
        }
    }

    int p, q;
    while( cin>>p>>q )
    {
            int x = gcd(p,q);
            int pp = p/x;
            int qq = q/x;
               if( xt[pp][qq] == -1 ) cout<<"Palindromic tree is better than splay tree";
               else
            cout<<xt[pp][qq]<<endl;
    }

//  solve();
}


#include <iostream>
#include <assert.h>
#include <stack>
#include <algorithm>
#include <queue>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <string.h>
#include <string>
#include <stdio.h>
#define sf scanf
#define pf printf
#define ll long long

#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i )
#define pb push_back

using namespace std;

int nima_pi[10000010];
int nima_rd[10000010];

int checkp( int t )
{
	int k = t, m = 0;
	while( k > 0 )
	{
		m = m * 10 + k % 10;
		k/=10;
	}
	return ( t == m );
}

int cnt;
int pr[1000000];
int is[10000010];
void init()
{
	cnt = 0;
	clr( is );
	int num = 10000000;
	for( int i = 2; i < num; ++i )
	{
		if( !is[i] )
		{
			pr[cnt++] = i;
		}
		for( int j = 0; j < cnt && pr[j] * i < num; ++j )
		{
			is[ i * pr[j] ] = 1;
		}
	}
	nima_pi[1] = 0;
	for( int i = 2; i < num; ++i )
	{
		nima_pi[i] = nima_pi[i-1] + (is[i]==0);
	}

	nima_rd[1] = 1;
	for( int i = 2; i < num; ++i )
	{
		nima_rd[i] = nima_rd[i-1] + checkp(i);
	}
	printf("40 = %d, %d\n",nima_pi[40], nima_rd[40]);
}

int pi( int n )
{
	return nima_pi[n];
}

int rd( int n )
{
	return nima_rd[n];
}

int xt[43][43];

int gcd( int a, int b )
{
	return b?gcd(b,a%b):a;
}

int xtt[43][43];
void solve()
{
	clr( xtt );
	int ret = -1;
	int num = 1000000;
	for( int i = 1; i < num; ++i )
	{
		int p1 = pi( i );
		int p2 = rd( i );

		for( int p = 1; p <=42; ++p )
		{
			int q = (ll)p2 * p /p1;
			xtt[p][q]=i;
		}
	}

	for( int p = 1; p <42; ++p )
	{
		for( int q = 1; q <=42; ++ q )
		{
			for( int qq = q; qq <= 42; ++qq )
			{
				xtt[p][q]= max( xtt[p][qq], xtt[p][q] );
			}

			if( xtt[p][q] != xt[p][q] )
			{
				printf("p = %d q = %d xt = %d xtt = %d\n",p,q,xt[p][q], xtt[p][q]);
			}
		}
	}
}

int main()
{
	_clr( nima_pi );
	_clr( nima_rd);
	_clr( xt );
	init();
	for( int p = 1; p < 43; ++p )
	{
		for( int q = 1; q <43; ++q )
		{
			int x = gcd(p,q);
			int pp = p/x;
			int qq = q/x;
			if( xt[pp][qq] != -1 )
			{
				continue;
			}

			int  num = 10000;

			if( p < 10 ) num = 148360;
			if( p < 20 ) num = 300000;
			if( p < 30 ) num = 600000;
			if( p < 40 ) num = 1000000;
			if( p >= 40 ) num = 1200000;
			if( q > 5 ) num /= 10;
			if( q > 10 ) num = 10000;
			if( q > 25 ) num = 200;

			int ret = -1;
			for( int i = 1; i < num; ++i )
			{
				int p1 = pi( i );
				int p2 = rd( i );
				if( p1 * qq <= p2 * pp )
				{
					ret = max( ret, i );
				}
			}
//			printf("p = %d q = %d ret = %d, %d %d\n",pp,qq,ret, pi(ret), rd(ret));
			xt[pp][qq] = ret;
		}
	}

	int p, q;
	while( cin>>p>>q )
	{
			int x = gcd(p,q);
			int pp = p/x;
			int qq = q/x;
			cout<<xt[pp][qq]<<endl;
	}

//	solve();
}


#include <iostream>
#include <assert.h>
#include <stack>
#include <algorithm>
#include <queue>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <string.h>
#include <string>
#include <stdio.h>
#define sf scanf
#define pf printf
#define ll long long

#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i )
#define pb push_back

using namespace std;

int nima_pi[10000010];
int nima_rd[10000010];

int checkp( int t )
{
    int k = t, m = 0;
    while( k > 0 )
    {
        m = m * 10 + k % 10;
        k/=10;
    }
    return ( t == m );
}

int cnt;
int pr[1000000];
int is[10000010];
void init()
{
    cnt = 0;
    clr( is );
    int num = 10000000;
    for( int i = 2; i < num; ++i )
    {
        if( !is[i] )
        {
            pr[cnt++] = i;
        }
        for( int j = 0; j < cnt && pr[j] * i < num; ++j )
        {
            is[ i * pr[j] ] = 1;
        }
    }
    nima_pi[1] = 0;
    for( int i = 2; i < num; ++i )
    {
        nima_pi[i] = nima_pi[i-1] + (is[i]==0);
    }

    nima_rd[1] = 1;
    for( int i = 2; i < num; ++i )
    {
        nima_rd[i] = nima_rd[i-1] + checkp(i);
    }
   // printf("40 = %d, %d\n",nima_pi[40], nima_rd[40]);
}

int pi( int n )
{
    return nima_pi[n];
}

int rd( int n )
{
    return nima_rd[n];
}

int xt[43][43];

int gcd( int a, int b )
{
    return b?gcd(b,a%b):a;
}

int xtt[43][43];
void solve()
{
    clr( xtt );
    int ret = -1;
    int num = 1000000;
    for( int i = 1; i < num; ++i )
    {
        int p1 = pi( i );
        int p2 = rd( i );

        for( int p = 1; p <=42; ++p )
        {
            int q = (ll)p2 * p /p1;
            xtt[p][q]=i;
        }
    }

    for( int p = 1; p <42; ++p )
    {
        for( int q = 1; q <=42; ++ q )
        {
            for( int qq = q; qq <= 42; ++qq )
            {
                xtt[p][q]= max( xtt[p][qq], xtt[p][q] );
            }

            if( xtt[p][q] != xt[p][q] )
            {
                printf("p = %d q = %d xt = %d xtt = %d\n",p,q,xt[p][q], xtt[p][q]);
            }
        }
    }
}

int main()
{
    _clr( nima_pi );
    _clr( nima_rd);
    _clr( xt );
    init();
    for( int p = 1; p < 43; ++p )
    {
        for( int q = 1; q <43; ++q )
        {
            int x = gcd(p,q);
            int pp = p/x;
            int qq = q/x;
            if( xt[pp][qq] != -1 )
            {
                continue;
            }

            int  num = 1000000;

            if( p >= 40 ) num = 1200000;

            int ret = -1;
            for( int i = 1; i < num; ++i )
            {
                int p1 = pi( i );
                int p2 = rd( i );
                if( p1 * qq <= p2 * pp )
                {
                    ret = max( ret, i );
                }
            }
//          printf("p = %d q = %d ret = %d, %d %d\n",pp,qq,ret, pi(ret), rd(ret));
            xt[pp][qq] = ret;
        }
    }

    int p, q;
    while( cin>>p>>q )
    {
            int x = gcd(p,q);
            int pp = p/x;
            int qq = q/x;
               if( xt[pp][qq] == -1 ) cout<<"Palindromic tree is better than splay tree";
               else
            cout<<xt[pp][qq]<<endl;
    }

//  solve();
}


#include <iostream>
#include <assert.h>
#include <stack>
#include <algorithm>
#include <queue>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <string.h>
#include <string>
#include <stdio.h>
#define sf scanf
#define pf printf
#define ll long long

#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i )
#define pb push_back

using namespace std;

int nima_pi[10000010];
int nima_rd[10000010];

int checkp( int t )
{
    int k = t, m = 0;
    while( k > 0 )
    {
        m = m * 10 + k % 10;
        k/=10;
    }
    return ( t == m );
}

int cnt;
int pr[1000000];
int is[10000010];
void init()
{
    cnt = 0;
    clr( is );
    int num = 10000000;
    for( int i = 2; i < num; ++i )
    {
        if( !is[i] )
        {
            pr[cnt++] = i;
        }
        for( int j = 0; j < cnt && pr[j] * i < num; ++j )
        {
            is[ i * pr[j] ] = 1;
        }
    }
    nima_pi[1] = 0;
    for( int i = 2; i < num; ++i )
    {
        nima_pi[i] = nima_pi[i-1] + (is[i]==0);
    }

    nima_rd[1] = 1;
    for( int i = 2; i < num; ++i )
    {
        nima_rd[i] = nima_rd[i-1] + checkp(i);
    }
    printf("40 = %d, %d\n",nima_pi[40], nima_rd[40]);
}

int pi( int n )
{
    return nima_pi[n];
}

int rd( int n )
{
    return nima_rd[n];
}

int xt[43][43];

int gcd( int a, int b )
{
    return b?gcd(b,a%b):a;
}

int xtt[43][43];
void solve()
{
    clr( xtt );
    int ret = -1;
    int num = 1000000;
    for( int i = 1; i < num; ++i )
    {
        int p1 = pi( i );
        int p2 = rd( i );

        for( int p = 1; p <=42; ++p )
        {
            int q = (ll)p2 * p /p1;
            xtt[p][q]=i;
        }
    }

    for( int p = 1; p <42; ++p )
    {
        for( int q = 1; q <=42; ++ q )
        {
            for( int qq = q; qq <= 42; ++qq )
            {
                xtt[p][q]= max( xtt[p][qq], xtt[p][q] );
            }

            if( xtt[p][q] != xt[p][q] )
            {
                printf("p = %d q = %d xt = %d xtt = %d\n",p,q,xt[p][q], xtt[p][q]);
            }
        }
    }
}

int main()
{
    _clr( nima_pi );
    _clr( nima_rd);
    _clr( xt );
    init();
    /*
    for( int p = 1; p < 43; ++p )
    {
        for( int q = 1; q <43; ++q )
        {
            int x = gcd(p,q);
            int pp = p/x;
            int qq = q/x;
            if( xt[pp][qq] != -1 )
            {
                continue;
            }

            int  num = 1200000;

            if( p < 10 ) num = 148360;
            if( p < 20 ) num = 300000;
            if( p < 30 ) num = 600000;
            if( p < 40 ) num = 1000000;
            if( p >= 40 ) num = 1200000;
            if( q > 5 ) num /= 10;
            if( q > 10 ) num = 10000;
            if( q > 25 ) num = 2000;

            int ret = -1;
            for( int i = 1; i < num; ++i )
            {
                int p1 = pi( i );
                int p2 = rd( i );
                if( p1 * qq <= p2 * pp )
                {
                    ret = max( ret, i );
                }
            }
            printf("p = %d q = %d ret = %d, %d %d\n",pp,qq,ret, pi(ret), rd(ret));
            xt[pp][qq] = ret;
        }
    }
    */

    int p, q;
    while( cin>>p>>q )
    {
        int ret = -1;
        for( int i = 1; i < 10000000; ++i )
        {
            ll p1 = pi( i );
            ll p2 = rd( i );
            int x = gcd(p,q);
            ll pp = p/x;
            ll qq = q/x;
            if( p1 * qq <= p2 * pp )
            {
                ret = max( ret, i );
            }
        }
        if( ret == -1 ) cout<<"Palindromic tree is better than splay tree";
        else
            cout<<ret<<endl;

    }

//  solve();
}


#include <iostream>
#include <assert.h>
#include <stack>
#include <algorithm>
#include <queue>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <string.h>
#include <string>
#include <stdio.h>
#define sf scanf
#define pf printf
#define ll long long

#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i )
#define pb push_back

using namespace std;

int nima_pi[10000010];
int nima_rd[10000010];

int checkp( int t )
{
    int k = t, m = 0;
    while( k > 0 )
    {
        m = m * 10 + k % 10;
        k/=10;
    }
    return ( t == m );
}

int cnt;
int pr[1000000];
int is[10000010];
void init()
{
    cnt = 0;
    clr( is );
    int num = 10000000;
    for( int i = 2; i < num; ++i )
    {
        if( !is[i] )
        {
            pr[cnt++] = i;
        }
        for( int j = 0; j < cnt && pr[j] * i < num; ++j )
        {
            is[ i * pr[j] ] = 1;
        }
    }
    nima_pi[1] = 0;
    for( int i = 2; i < num; ++i )
    {
        nima_pi[i] = nima_pi[i-1] + (is[i]==0);
    }

    nima_rd[1] = 1;
    for( int i = 2; i < num; ++i )
    {
        nima_rd[i] = nima_rd[i-1] + checkp(i);
    }
  //  printf("40 = %d, %d\n",nima_pi[40], nima_rd[40]);
}

int pi( int n )
{
    return nima_pi[n];
}

int rd( int n )
{
    return nima_rd[n];
}

int xt[43][43];

int gcd( int a, int b )
{
    return b?gcd(b,a%b):a;
}

int xtt[43][43];
void solve()
{
    clr( xtt );
    int ret = -1;
    int num = 1000000;
    for( int i = 1; i < num; ++i )
    {
        int p1 = pi( i );
        int p2 = rd( i );

        for( int p = 1; p <=42; ++p )
        {
            int q = (ll)p2 * p /p1;
            xtt[p][q]=i;
        }
    }

    for( int p = 1; p <42; ++p )
    {
        for( int q = 1; q <=42; ++ q )
        {
            for( int qq = q; qq <= 42; ++qq )
            {
                xtt[p][q]= max( xtt[p][qq], xtt[p][q] );
            }

            if( xtt[p][q] != xt[p][q] )
            {
                printf("p = %d q = %d xt = %d xtt = %d\n",p,q,xt[p][q], xtt[p][q]);
            }
        }
    }
}

int main()
{
    _clr( nima_pi );
    _clr( nima_rd);
    _clr( xt );
    init();
    /*
    for( int p = 1; p < 43; ++p )
    {
        for( int q = 1; q <43; ++q )
        {
            int x = gcd(p,q);
            int pp = p/x;
            int qq = q/x;
            if( xt[pp][qq] != -1 )
            {
                continue;
            }

            int  num = 1200000;

            if( p < 10 ) num = 148360;
            if( p < 20 ) num = 300000;
            if( p < 30 ) num = 600000;
            if( p < 40 ) num = 1000000;
            if( p >= 40 ) num = 1200000;
            if( q > 5 ) num /= 10;
            if( q > 10 ) num = 10000;
            if( q > 25 ) num = 2000;

            int ret = -1;
            for( int i = 1; i < num; ++i )
            {
                int p1 = pi( i );
                int p2 = rd( i );
                if( p1 * qq <= p2 * pp )
                {
                    ret = max( ret, i );
                }
            }
            printf("p = %d q = %d ret = %d, %d %d\n",pp,qq,ret, pi(ret), rd(ret));
            xt[pp][qq] = ret;
        }
    }
    */

    int p, q;
    while( cin>>p>>q )
    {
        int ret = -1;
        for( int i = 1; i < 10000000; ++i )
        {
            ll p1 = pi( i );
            ll p2 = rd( i );
            int x = gcd(p,q);
            ll pp = p/x;
            ll qq = q/x;
            if( p1 * qq <= p2 * pp )
            {
                ret = max( ret, i );
            }
        }
        if( ret == -1 ) cout<<"Palindromic tree is better than splay tree";
        else
            cout<<ret<<endl;

    }

//  solve();
}


#include <iostream>
#include <assert.h>
#include <stack>
#include <algorithm>
#include <queue>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <string.h>
#include <string>
#include <stdio.h>
#define sf scanf
#define pf printf
#define ll long long

#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i )
#define pb push_back

using namespace std;

int nima_pi[10000010];
int nima_rd[10000010];

int checkp( int t )
{
    int k = t, m = 0;
    while( k > 0 )
    {
        m = m * 10 + k % 10;
        k/=10;
    }
    return ( t == m );
}

int cnt;
int pr[1000000];
int is[10000010];
void init()
{
    cnt = 0;
    clr( is );
    int num = 10000000;
    for( int i = 2; i < num; ++i )
    {
        if( !is[i] )
        {
            pr[cnt++] = i;
        }
        for( int j = 0; j < cnt && pr[j] * i < num; ++j )
        {
            is[ i * pr[j] ] = 1;
        }
    }
    nima_pi[1] = 0;
    for( int i = 2; i < num; ++i )
    {
        nima_pi[i] = nima_pi[i-1] + (is[i]==0);
    }

    nima_rd[1] = 1;
    for( int i = 2; i < num; ++i )
    {
        nima_rd[i] = nima_rd[i-1] + checkp(i);
    }
   // printf("40 = %d, %d\n",nima_pi[40], nima_rd[40]);
}

int pi( int n )
{
    return nima_pi[n];
}

int rd( int n )
{
    return nima_rd[n];
}

int xt[43][43];

int gcd( int a, int b )
{
    return b?gcd(b,a%b):a;
}

int xtt[43][43];
void solve()
{
    clr( xtt );
    int ret = -1;
    int num = 1000000;
    for( int i = 1; i < num; ++i )
    {
        int p1 = pi( i );
        int p2 = rd( i );

        for( int p = 1; p <=42; ++p )
        {
            int q = (ll)p2 * p /p1;
            xtt[p][q]=i;
        }
    }

    for( int p = 1; p <42; ++p )
    {
        for( int q = 1; q <=42; ++ q )
        {
            for( int qq = q; qq <= 42; ++qq )
            {
                xtt[p][q]= max( xtt[p][qq], xtt[p][q] );
            }

            if( xtt[p][q] != xt[p][q] )
            {
                printf("p = %d q = %d xt = %d xtt = %d\n",p,q,xt[p][q], xtt[p][q]);
            }
        }
    }
}

int main()
{
    _clr( nima_pi );
    _clr( nima_rd);
    _clr( xt );
    init();
    /*
    for( int p = 1; p < 43; ++p )
    {
        for( int q = 1; q <43; ++q )
        {
            int x = gcd(p,q);
            int pp = p/x;
            int qq = q/x;
            if( xt[pp][qq] != -1 )
            {
                continue;
            }

            int  num = 1200000;

            if( p < 10 ) num = 148360;
            if( p < 20 ) num = 300000;
            if( p < 30 ) num = 600000;
            if( p < 40 ) num = 1000000;
            if( p >= 40 ) num = 1200000;
            if( q > 5 ) num /= 10;
            if( q > 10 ) num = 10000;
            if( q > 25 ) num = 2000;

            int ret = -1;
            for( int i = 1; i < num; ++i )
            {
                int p1 = pi( i );
                int p2 = rd( i );
                if( p1 * qq <= p2 * pp )
                {
                    ret = max( ret, i );
                }
            }
            printf("p = %d q = %d ret = %d, %d %d\n",pp,qq,ret, pi(ret), rd(ret));
            xt[pp][qq] = ret;
        }
    }
    */

    int p, q;
    while( cin>>p>>q )
    {
        int ret = -1;
        for( int i = 1; i < 10000000; ++i )
        {
            int p1 = pi( i );
            int p2 = rd( i );
            if( p1 * q <= p2 * p )
            {
                ret = max( ret, i );
            }
        }
        if( ret == -1 ) cout<<"Palindromic tree is better than splay tree";
        else
            cout<<ret<<endl;

    }

//  solve();
}


#include <iostream>
#include <assert.h>
#include <stack>
#include <algorithm>
#include <queue>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <string.h>
#include <string>
#include <stdio.h>
#define sf scanf
#define pf printf
#define ll long long

#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i )
#define pb push_back

using namespace std;

int nima_pi[10000010];
int nima_rd[10000010];

int checkp( int t )
{
    int k = t, m = 0;
    while( k > 0 )
    {
        m = m * 10 + k % 10;
        k/=10;
    }
    return ( t == m );
}

int cnt;
int pr[1000000];
int is[10000010];
void init()
{
    cnt = 0;
    clr( is );
    int num = 10000000;
    for( int i = 2; i < num; ++i )
    {
        if( !is[i] )
        {
            pr[cnt++] = i;
        }
        for( int j = 0; j < cnt && pr[j] * i < num; ++j )
        {
            is[ i * pr[j] ] = 1;
        }
    }
    nima_pi[1] = 0;
    for( int i = 2; i < num; ++i )
    {
        nima_pi[i] = nima_pi[i-1] + (is[i]==0);
    }

    nima_rd[1] = 1;
    for( int i = 2; i < num; ++i )
    {
        nima_rd[i] = nima_rd[i-1] + checkp(i);
    }
   // printf("40 = %d, %d\n",nima_pi[40], nima_rd[40]);
}

int pi( int n )
{
    return nima_pi[n];
}

int rd( int n )
{
    return nima_rd[n];
}

int xt[43][43];

int gcd( int a, int b )
{
    return b?gcd(b,a%b):a;
}

int xtt[43][43];
void solve()
{
    clr( xtt );
    int ret = -1;
    int num = 1000000;
    for( int i = 1; i < num; ++i )
    {
        int p1 = pi( i );
        int p2 = rd( i );

        for( int p = 1; p <=42; ++p )
        {
            int q = (ll)p2 * p /p1;
            xtt[p][q]=i;
        }
    }

    for( int p = 1; p <42; ++p )
    {
        for( int q = 1; q <=42; ++ q )
        {
            for( int qq = q; qq <= 42; ++qq )
            {
                xtt[p][q]= max( xtt[p][qq], xtt[p][q] );
            }

            if( xtt[p][q] != xt[p][q] )
            {
                printf("p = %d q = %d xt = %d xtt = %d\n",p,q,xt[p][q], xtt[p][q]);
            }
        }
    }
}

int main()
{
    _clr( nima_pi );
    _clr( nima_rd);
    _clr( xt );
    init();
    for( int p = 1; p < 43; ++p )
    {
        for( int q = 1; q <43; ++q )
        {
            int x = gcd(p,q);
            int pp = p/x;
            int qq = q/x;
            if( xt[pp][qq] != -1 )
            {
                continue;
            }

            int  num = 10000;

            if( p < 10 ) num = 148360;
            if( p < 20 ) num = 300000;
            if( p < 30 ) num = 600000;
            if( p < 40 ) num = 1000000;
            if( p >= 40 ) num = 1200000;
            if( q > 5 ) num /= 10;
            if( q > 10 ) num = 10000;
            if( q > 25 ) num = 200;

            int ret = -1;
            for( int i = 1; i < num; ++i )
            {
                int p1 = pi( i );
                int p2 = rd( i );
                if( p1 * qq <= p2 * pp )
                {
                    ret = max( ret, i );
                }
            }
//          printf("p = %d q = %d ret = %d, %d %d\n",pp,qq,ret, pi(ret), rd(ret));
            xt[pp][qq] = ret;
        }
    }

    int p, q;
    while( cin>>p>>q )
    {
            int x = gcd(p,q);
            int pp = p/x;
            int qq = q/x;
               if( xt[pp][qq] == -1 ) cout<<"Palindromic tree is better than splay tree";
               else
            cout<<xt[pp][qq]<<endl;
    }

//  solve();
}


#include <iostream>
#include <assert.h>
#include <stack>
#include <algorithm>
#include <queue>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <string.h>
#include <string>
#include <stdio.h>
#define sf scanf
#define pf printf
#define ll long long

#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i )
#define pb push_back

using namespace std;

int nima_pi[10000010];
int nima_rd[10000010];

int checkp( int t )
{
    int k = t, m = 0;
    while( k > 0 )
    {
        m = m * 10 + k % 10;
        k/=10;
    }
    return ( t == m );
}

int cnt;
int pr[1000000];
int is[10000010];
void init()
{
    cnt = 0;
    clr( is );
    int num = 10000000;
    for( int i = 2; i < num; ++i )
    {
        if( !is[i] )
        {
            pr[cnt++] = i;
        }
        for( int j = 0; j < cnt && pr[j] * i < num; ++j )
        {
            is[ i * pr[j] ] = 1;
        }
    }
    nima_pi[1] = 0;
    for( int i = 2; i < num; ++i )
    {
        nima_pi[i] = nima_pi[i-1] + (is[i]==0);
    }

    nima_rd[1] = 1;
    for( int i = 2; i < num; ++i )
    {
        nima_rd[i] = nima_rd[i-1] + checkp(i);
    }
   // printf("40 = %d, %d\n",nima_pi[40], nima_rd[40]);
}

int pi( int n )
{
    return nima_pi[n];
}

int rd( int n )
{
    return nima_rd[n];
}

int xt[43][43];

int gcd( int a, int b )
{
    return b?gcd(b,a%b):a;
}

int xtt[43][43];
void solve()
{
    clr( xtt );
    int ret = -1;
    int num = 1000000;
    for( int i = 1; i < num; ++i )
    {
        int p1 = pi( i );
        int p2 = rd( i );

        for( int p = 1; p <=42; ++p )
        {
            int q = (ll)p2 * p /p1;
            xtt[p][q]=i;
        }
    }

    for( int p = 1; p <42; ++p )
    {
        for( int q = 1; q <=42; ++ q )
        {
            for( int qq = q; qq <= 42; ++qq )
            {
                xtt[p][q]= max( xtt[p][qq], xtt[p][q] );
            }

            if( xtt[p][q] != xt[p][q] )
            {
                printf("p = %d q = %d xt = %d xtt = %d\n",p,q,xt[p][q], xtt[p][q]);
            }
        }
    }
}

int main()
{
    _clr( nima_pi );
    _clr( nima_rd);
    _clr( xt );
    init();
    for( int p = 1; p < 43; ++p )
    {
        for( int q = 1; q <43; ++q )
        {
            int x = gcd(p,q);
            int pp = p/x;
            int qq = q/x;
            if( xt[pp][qq] != -1 )
            {
                continue;
            }

            int  num = 10000;

            if( p < 10 ) num = 148360;
            if( p < 20 ) num = 300000;
            if( p < 30 ) num = 600000;
            if( p < 40 ) num = 1000000;
            if( p >= 40 ) num = 1200000;
            if( q > 5 ) num /= 10;
            if( q > 10 ) num = 10000;
            if( q > 25 ) num = 200;

            int ret = -1;
            for( int i = 1; i < num; ++i )
            {
                int p1 = pi( i );
                int p2 = rd( i );
                if( p1 * qq <= p2 * pp )
                {
                    ret = max( ret, i );
                }
            }
//          printf("p = %d q = %d ret = %d, %d %d\n",pp,qq,ret, pi(ret), rd(ret));
            xt[pp][qq] = ret;
        }
    }

    int p, q;
    while( cin>>p>>q )
    {
            int x = gcd(p,q);
            int pp = p/x;
            int qq = q/x;
            cout<<xt[pp][qq]<<endl;
    }

//  solve();
}


#include <iostream>
#include <assert.h>
#include <stack>
#include <algorithm>
#include <queue>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <string.h>
#include <string>
#include <stdio.h>
#define sf scanf
#define pf printf
#define ll long long

#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i )
#define pb push_back

using namespace std;

int nima_pi[10000010];
int nima_rd[10000010];

int checkp( int t )
{
    int k = t, m = 0;
    while( k > 0 )
    {
        m = m * 10 + k % 10;
        k/=10;
    }
    return ( t == m );
}

int cnt;
int pr[1000000];
int is[10000010];
void init()
{
    cnt = 0;
    clr( is );
    int num = 10000000;
    for( int i = 2; i < num; ++i )
    {
        if( !is[i] )
        {
            pr[cnt++] = i;
        }
        for( int j = 0; j < cnt && pr[j] * i < num; ++j )
        {
            is[ i * pr[j] ] = 1;
        }
    }
    nima_pi[1] = 0;
    for( int i = 2; i < num; ++i )
    {
        nima_pi[i] = nima_pi[i-1] + (is[i]==0);
    }

    nima_rd[1] = 1;
    for( int i = 2; i < num; ++i )
    {
        nima_rd[i] = nima_rd[i-1] + checkp(i);
    }
   // printf("40 = %d, %d\n",nima_pi[40], nima_rd[40]);
}

int pi( int n )
{
    return nima_pi[n];
}

int rd( int n )
{
    return nima_rd[n];
}

int xt[43][43];

int gcd( int a, int b )
{
    return b?gcd(b,a%b):a;
}

int xtt[43][43];
void solve()
{
    clr( xtt );
    int ret = -1;
    int num = 1000000;
    for( int i = 1; i < num; ++i )
    {
        int p1 = pi( i );
        int p2 = rd( i );

        for( int p = 1; p <=42; ++p )
        {
            int q = (ll)p2 * p /p1;
            xtt[p][q]=i;
        }
    }

    for( int p = 1; p <42; ++p )
    {
        for( int q = 1; q <=42; ++ q )
        {
            for( int qq = q; qq <= 42; ++qq )
            {
                xtt[p][q]= max( xtt[p][qq], xtt[p][q] );
            }

            if( xtt[p][q] != xt[p][q] )
            {
                printf("p = %d q = %d xt = %d xtt = %d\n",p,q,xt[p][q], xtt[p][q]);
            }
        }
    }
}

int main()
{
    _clr( nima_pi );
    _clr( nima_rd);
    _clr( xt );
    init();
    for( int p = 1; p < 43; ++p )
    {
        for( int q = 1; q <43; ++q )
        {
            int x = gcd(p,q);
            int pp = p/x;
            int qq = q/x;
            if( xt[pp][qq] != -1 )
            {
                continue;
            }

            int  num = 10000;

            if( p < 10 ) num = 148360;
            if( p < 20 ) num = 300000;
            if( p < 30 ) num = 600000;
            if( p < 40 ) num = 1000000;
            if( p >= 40 ) num = 1200000;
            if( q > 5 ) num /= 10;
            if( q > 10 ) num = 10000;
            if( q > 25 ) num = 200;

            int ret = 1;
            for( int i = 1; i < num; ++i )
            {
                int p1 = pi( i );
                int p2 = rd( i );
                if( p1 * qq <= p2 * pp )
                {
                    ret = max( ret, i );
                }
            }
//          printf("p = %d q = %d ret = %d, %d %d\n",pp,qq,ret, pi(ret), rd(ret));
            xt[pp][qq] = ret;
        }
    }

    int p, q;
    while( cin>>p>>q )
    {
            int x = gcd(p,q);
            int pp = p/x;
            int qq = q/x;
               if( xt[pp][qq] == -1 ) cout<<"Palindromic tree is better than splay tree";
               else
            cout<<xt[pp][qq]<<endl;
    }

//  solve();
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<cstdlib>
#include<queue>
using namespace std;

#define pb push_back
#define mp make_pair
#define sc second
#define ft first

#define FOR(i,N) for (int i=1; i<=N; i++)
#define REP(i,l,r) for (int i=l; i<=r; i++)

#define INF ~0U>>1
#define eps 1e-9

const int maxn = 8000010;
const int N = 4000;
int vis[maxn], pow[maxn], prime[maxn], phi[maxn], Log[maxn], rub[maxn];
int p, q, tot, dp[maxn];

int main ()
{
#ifndef ONLINE_JUDGE
#ifndef MEKTPOY
	freopen (".in", "r", stdin);
	freopen (".out", "w", stdout);
#else
	//freopen ("in.txt", "r", stdin);
#endif
#endif
	cin >> p >> q;
	pow[0] = 1; phi[1] = 0;
	for (int i=2; i<=N; i++)
	{
		if (!vis[i]) prime[++tot] = i, phi[i] = phi[i-1]+1;
		else phi[i] = phi[i-1];
		for (int j=1; j<=tot; j++)
			{
				if (i*prime[j] > N) break;
				vis[i*prime[j]] = 1;
				if (i%prime[j] == 0) break;
			}
	}
	for (int i=0; i<=9; i++) Log[i] = 1;
	for (int i=10; i<=N; i++)
		Log[i] = Log[i/10]*10;
	for (int i=0; i<=9; i++) dp[i] = 1;
	for (int i=10; i<=N; i++)
	{
		char S[20] = "";
		sprintf (S, "%d", i);
		int flag = 1;
		for (int k=0; k<strlen(S); k++)
			if (S[k] != S[strlen(S)-k-1]) flag = 0;
		dp[i] = flag;
	}
	for (int i=1; i<=N; i++)
		rub[i] = rub[i-1]+dp[i];
	for (int i=N; i>=1; i--)
		if (p*rub[i] >= q*phi[i]) return printf ("%d\n", i), 0;
	puts ("Palindromic tree is better than splay tree");
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<cstdlib>
#include<queue>
using namespace std;

#define pb push_back
#define mp make_pair
#define sc second
#define ft first

#define FOR(i,N) for (int i=1; i<=N; i++)
#define REP(i,l,r) for (int i=l; i<=r; i++)

#define INF ~0U>>1
#define eps 1e-9

const int maxn = 8000010;
const int N = 8000000;
int vis[maxn], pow[maxn], prime[maxn], phi[maxn], Log[maxn], rub[maxn];
int p, q, tot, dp[maxn];

int main ()
{
#ifndef ONLINE_JUDGE
#ifndef MEKTPOY
	freopen (".in", "r", stdin);
	freopen (".out", "w", stdout);
#else
	//freopen ("in.txt", "r", stdin);
#endif
#endif
	cin >> p >> q;
	pow[0] = 1; phi[1] = 0;
	for (int i=2; i<=N; i++)
	{
		if (!vis[i]) prime[++tot] = i, phi[i] = phi[i-1]+1;
		else phi[i] = phi[i-1];
		for (int j=1; j<=tot; j++)
			{
				if (i*prime[j] > N) break;
				vis[i*prime[j]] = 1;
				if (i%prime[j] == 0) break;
			}
	}
	for (int i=0; i<=9; i++) dp[i] = 1;
	for (int i=10; i<=N; i++)
	{
		char S[20] = "";
		sprintf (S, "%d", i);
		int flag = 1;
		for (int k=0; k<strlen(S); k++)
			if (S[k] != S[strlen(S)-k-1]) flag = 0;
		dp[i] = flag;
	}
	for (int i=1; i<=N; i++)
		rub[i] = rub[i-1]+dp[i];
	for (int i=N; i>=1; i--)
		if (1LL*p*rub[i] >= 1LL*q*phi[i]) return printf ("%d\n", i), 0;
	puts ("Palindromic tree is better than splay tree");
	return 0;
}


from sys import stdin as f
t = int(f.readline().strip())
for _ in range(t):
    n, m = [int(i) for i in f.readline().strip().split()]
    matrix = []
    for i in range(n):
        matrix.append([int(j) for j in f.readline().strip().split()])
    zero_rows = get_zero_rows(matrix)
    zero_columns = get_zero_rows(zip(*matrix))
    moves_count = min(zero_rows, zero_columns)
    if moves_count % 2 == 1:
        print('Ashish')
    else:
        print('Vivek')


from sys import stdin as f

def get_zero_rows(matrix):
    return len([row for row in matrix if sum(row) == 0])

t = int(f.readline().strip())
for _ in range(t):
    n, m = [int(i) for i in f.readline().strip().split()]
    matrix = []
    for i in range(n):
        matrix.append([int(j) for j in f.readline().strip().split()])
    zero_rows = get_zero_rows(matrix)
    zero_columns = get_zero_rows(zip(*matrix))
    moves_count = min(zero_rows, zero_columns)
    if moves_count % 2 == 1:
        print('Ashish')
    else:
        print('Vivek')


for _ in range(input()):
    r, c = map(int, raw_input().split())
    mat = []
    rc = 0
    for i in range(r):
        mat.append(map(int, raw_input().split()))
        if 1 not in mat[i]:
            rc += 1

    cc = 0
    for i in range(c):
        found = False
        for j in range(r):
            if mat[j][i] == 1:
                found = True
                break
        if not found:
            cc += 1

    if min(rc, cc) % 2 == 0:
        print "Vivek"
    else:
        print "Ashish"


for _ in range(input()):
    r, c = map(int, raw_input().split())
    mat = []
    rc = 0
    for i in range(r):
        mat.append(map(int, raw_input().split()))
        if 1 not in mat[i]:
            rc += 1

    if rc % 2 == 0:
        print "Vivek"
    else:
        print "Ashish"


import atexit, io, sys

# A stream implementation using an in-memory bytes
# buffer. It inherits BufferedIOBase.

buffer = io.BytesIO()

sys.stdout = buffer

# print via here

@atexit.register

def write():

    sys.__stdout__.write(buffer.getvalue())
for _ in range(input()):
    n,m=map(int,raw_input().split())
    cr,cc=n,m;p=[]
    for i in range(n):
        a=map(int,raw_input().split())
        if 1 in a:
            cr-=1
        p.append(a)
    for j in range(m):
        for i in range(n):
             if p[i][j]==1:
                 cc-=1;break
    t=min(cr,cc)
    if t%2:
        print "Ashish"
    else:
        print "Vivek"


T = input()
for t in range(T) :
  N, M = map(int,raw_input().split())
  rows = set(range(N))
  cols = set(range(M))

  for n in range(N) :
    row = map(int,raw_input().split())
    for m in range(M) :
      if row[m] == 1 :
        rows.discard(n)
        cols.discard(m)

  d = min(len(rows), len(cols))
  print "Vivek" if d % 2 == 0 else "Ashish"


T = input()
for t in range(T) :
  N, M = map(int,raw_input().split())
  rows = set(range(N))
  cols = set(range(M))

  for n in range(N) :
    row = map(int,raw_input().split())
    for m in range(M) :
      if row[m] == 1 :
        rows.discard(n)
        rows.discard(m)

  d = min(len(rows), len(cols))
  print "Vivek" if d % 2 == 0 else "Ashish"


def soln(R, C, matrix):
    numUnset = 0
    unsetRows = 0
    for r in range(R):
        if all(matrix[r][c] == 0 for c in range(C)):
            unsetRows += 1
    unsetCols = 0
    for c in range(C):
        if all(matrix[r][c] == 0 for r in range(R)):
            unsetCols += 1
    numUnset = min(unsetCols, unsetRows)
    # print(numUnset)
    if numUnset % 2 == 0:
        return 'Vivek'
    return 'Ashish'

def brute(R, C, matrix):
    memo = {}
    def dp(rows, cols):
        hashVal = f'{rows}, {cols}'
        if hashVal in memo:
            return memo[hashVal]
        result = True
        if len(rows) == 0 or len(cols) == 0:
            result = False
        else:
            for r, row in enumerate(rows):
                # first = True
                # if dp(rows[:r] + rows[r+1:], cols):
                #     result = False
                #     break
                for c, col in enumerate(cols):
                    # if first:
                    #     first = False
                    #     if dp(rows, cols[:c] + cols[c+1:]):
                    #         result = False
                    #         break
                    if dp(rows[:r] + rows[r+1:], cols[:c] + cols[c+1:]):
                        result = False
                        break
                if not result:
                    break
        # print(rows, cols, result)
        memo[hashVal] = result
        return result

    rows = []
    for r in range(R):
        if not any(matrix[r][c] == 1 for c in range(C)):
            rows.append(r)
    cols = []
    for c in range(C):
        if not any(matrix[r][c] == 1 for r in range(R)):
            cols.append(c)
    ashish = dp(rows, cols)
    if ashish:
        return 'Ashish'
    return 'Vivek'

# def randomTest():
#     import random
#     t = 100
#     for i in range(1, t + 1):
#         R = random.randint(2, 7)
#         C = random.randint(2, 7)
#         matrix = [
#             [1 if random.random() > 0.8 else 0 for _ in range(C)] for _ in range(R)
#         ]
#         print(f'{(i, R, C) = }')
#         b = brute(R, C, matrix)
#         f = soln(R, C, matrix)
#         try:
#             assert(b == f)
#         except:
#             from lesterlib import lestermatrix
#             print('Failed!')
#             lestermatrix.printMatrix(matrix)
#             print(f'{(b, f) = }')
#             break

def test():
    R, C = 6, 5
    matrix = [
   [0,   0,   0,   1,   0,],
   [0,   0,   1,   0,   0,],
   [0,   0,   1,   0,   1,],
   [0,   0,   0,   0,   1,],
   [0,   0,   0,   0,   0,],
   [0,   0,   0,   0,   0,],
    ]
    b = brute(R, C, matrix)
    f = soln(R, C, matrix)
    print(b, f)

def main():
    t = int(input())
    for _ in range(t):
        R, C = [int(x) for x in input().split()]
        matrix = []
        for _ in range(R):
            row = [int(x) for x in input().split()]
            matrix.append(row)
        result = soln(R, C, matrix)
        # result = brute(R, C, matrix)
        print(result)

if __name__ == "__main__":
    main()
    # randomTest()
    # test()


def soln(m, n, matrix):
    size = min(m, n)
    numUnset = size
    for r in range(size):
        if any(matrix[r][c] == 1 for c in range(size)):
            numUnset -= 1
    if numUnset % 2 == 0:
        return 'Vivek'
    return 'Ashish'

def main():
    t = int(input())
    for _ in range(t):
        n, m = [int(x) for x in input().split()]
        matrix = []
        for _ in range(n):
            row = [int(x) for x in input().split()]
            matrix.append(row)
        result = soln(m, n, matrix)
        # result = brute(arr, x)
        print(result)

if __name__ == "__main__":
    main()
    # randomTest()


def soln(R, C, matrix):
    numUnset = min(R, C)
    for r in range(R):
        if any(matrix[r][c] == 1 for c in range(C)):
            numUnset -= 1
    if numUnset % 2 == 0:
        return 'Vivek'
    return 'Ashish'

def main():
    t = int(input())
    for _ in range(t):
        R, C = [int(x) for x in input().split()]
        matrix = []
        for _ in range(R):
            row = [int(x) for x in input().split()]
            matrix.append(row)
        result = soln(R, C, matrix)
        # result = brute(arr, x)
        print(result)

if __name__ == "__main__":
    main()
    # randomTest()


def soln(R, C, matrix):
    size = min(R, C)
    numUnset = size
    for r in range(size):
        if any(matrix[r][c] == 1 for c in range(C)):
            numUnset -= 1
    if numUnset % 2 == 0:
        return 'Vivek'
    return 'Ashish'

def main():
    t = int(input())
    for _ in range(t):
        R, C = [int(x) for x in input().split()]
        matrix = []
        for _ in range(R):
            row = [int(x) for x in input().split()]
            matrix.append(row)
        result = soln(R, C, matrix)
        # result = brute(arr, x)
        print(result)

if __name__ == "__main__":
    main()
    # randomTest()


def soln(R, C, matrix):
    numUnset = min(R, C)
    for r in range(R):
        if any(matrix[r][c] == 1 for c in range(C)):
            numUnset -= 1
    if numUnset % 3 == 0:
        return 'Vivek'
    return 'Ashish'

def brute(R, C, matrix):
    memo = {}
    def dp(rows, cols):
        result = True
        if len(rows) == 0 or len(cols) == 0:
            result = False
        else:
            for r, row in enumerate(rows):
                # first = True
                # if dp(rows[:r] + rows[r+1:], cols):
                #     result = False
                #     break
                for c, col in enumerate(cols):
                    # if first:
                    #     first = False
                    #     if dp(rows, cols[:c] + cols[c+1:]):
                    #         result = False
                    #         break
                    if dp(rows[:r] + rows[r+1:], cols[:c] + cols[c+1:]):
                        result = False
                        break
                if not result:
                    break
        # print(rows, cols, result)
        return result

    rows = []
    for r in range(R):
        if not any(matrix[r][c] == 1 for c in range(C)):
            rows.append(r)
    cols = []
    for c in range(C):
        if not any(matrix[r][c] == 1 for r in range(R)):
            cols.append(c)
    ashish = dp(rows, cols)
    if ashish:
        return 'Ashish'
    return 'Vivek'

def main():
    t = int(input())
    for _ in range(t):
        R, C = [int(x) for x in input().split()]
        matrix = []
        for _ in range(R):
            row = [int(x) for x in input().split()]
            matrix.append(row)
        # result = soln(R, C, matrix)
        result = brute(R, C, matrix)
        print(result)

if __name__ == "__main__":
    main()
    # randomTest()


def soln(R, C, matrix):
    numUnset = 0
    unsetRows = 0
    for r in range(R):
        if all(matrix[r][c] == 0 for c in range(C)):
            unsetRows += 1
    unsetCols = 0
    for c in range(C):
        if all(matrix[r][c] == 0 for r in range(R)):
            unsetCols += 1
    numUnset = min(unsetCols, unsetRows)
    # print(numUnset)
    if numUnset % 2 == 0:
        return 'Vivek'
    return 'Ashish'

def brute(R, C, matrix):
    memo = {}
    def dp(rows, cols):
        hashVal = f'{rows}, {cols}'
        if hashVal in memo:
            return memo[hashVal]
        result = True
        if len(rows) == 0 or len(cols) == 0:
            result = False
        else:
            for r, row in enumerate(rows):
                # first = True
                # if dp(rows[:r] + rows[r+1:], cols):
                #     result = False
                #     break
                for c, col in enumerate(cols):
                    # if first:
                    #     first = False
                    #     if dp(rows, cols[:c] + cols[c+1:]):
                    #         result = False
                    #         break
                    if dp(rows[:r] + rows[r+1:], cols[:c] + cols[c+1:]):
                        result = False
                        break
                if not result:
                    break
        # print(rows, cols, result)
        memo[hashVal] = result
        return result

    rows = []
    for r in range(R):
        if not any(matrix[r][c] == 1 for c in range(C)):
            rows.append(r)
    cols = []
    for c in range(C):
        if not any(matrix[r][c] == 1 for r in range(R)):
            cols.append(c)
    ashish = dp(rows, cols)
    if ashish:
        return 'Ashish'
    return 'Vivek'

# def randomTest():
#     import random
#     t = 100
#     for i in range(1, t + 1):
#         R = random.randint(2, 7)
#         C = random.randint(2, 7)
#         matrix = [
#             [1 if random.random() > 0.8 else 0 for _ in range(C)] for _ in range(R)
#         ]
#         print(f'{(i, R, C) = }')
#         b = brute(R, C, matrix)
#         f = soln(R, C, matrix)
#         try:
#             assert(b == f)
#         except:
#             from lesterlib import lestermatrix
#             print('Failed!')
#             lestermatrix.printMatrix(matrix)
#             print(f'{(b, f) = }')
#             break

def test():
    R, C = 6, 5
    matrix = [
   [0,   0,   0,   1,   0,],
   [0,   0,   1,   0,   0,],
   [0,   0,   1,   0,   1,],
   [0,   0,   0,   0,   1,],
   [0,   0,   0,   0,   0,],
   [0,   0,   0,   0,   0,],
    ]
    b = brute(R, C, matrix)
    f = soln(R, C, matrix)
    print(b, f)

def main():
    t = int(input())
    for _ in range(t):
        R, C = [int(x) for x in input().split()]
        matrix = []
        for _ in range(R):
            row = [int(x) for x in input().split()]
            matrix.append(row)
        # result = soln(R, C, matrix)
        result = brute(R, C, matrix)
        print(result)

if __name__ == "__main__":
    main()
    # randomTest()
    # test()


def soln(R, C, matrix):
    numUnset = min(R, C)
    for r in range(R):
        if any(matrix[r][c] == 1 for c in range(C)):
            numUnset -= 1
    if numUnset % 3 == 0:
        return 'Vivek'
    return 'Ashish'

def brute(R, C, matrix):
    memo = {}
    def dp(rows, cols):
        hashVal = f'{rows}, {cols}'
        if hashVal in memo:
            return memo[hashVal]
        result = True
        if len(rows) == 0 or len(cols) == 0:
            result = False
        else:
            for r, row in enumerate(rows):
                # first = True
                # if dp(rows[:r] + rows[r+1:], cols):
                #     result = False
                #     break
                for c, col in enumerate(cols):
                    # if first:
                    #     first = False
                    #     if dp(rows, cols[:c] + cols[c+1:]):
                    #         result = False
                    #         break
                    if dp(rows[:r] + rows[r+1:], cols[:c] + cols[c+1:]):
                        result = False
                        break
                if not result:
                    break
        # print(rows, cols, result)
        memo[hashVal] = result
        return result

    rows = []
    for r in range(R):
        if not any(matrix[r][c] == 1 for c in range(C)):
            rows.append(r)
    cols = []
    for c in range(C):
        if not any(matrix[r][c] == 1 for r in range(R)):
            cols.append(c)
    ashish = dp(rows, cols)
    if ashish:
        return 'Ashish'
    return 'Vivek'

def randomTest():
    pass

def main():
    t = int(input())
    for _ in range(t):
        R, C = [int(x) for x in input().split()]
        matrix = []
        for _ in range(R):
            row = [int(x) for x in input().split()]
            matrix.append(row)
        # result = soln(R, C, matrix)
        result = brute(R, C, matrix)
        print(result)

if __name__ == "__main__":
    main()
    # randomTest()


def row_s(a, n, m):
    ans = 0
    for j in range(m):
        for i in range(n):
            if a[i][j] == 1:
                ans += 1
                break
    return ans

for _ in range(int(input())):
    ones = 0
    n, m = [int(s) for s in input().split()]
    a = [[int(s) for s in input().split()] for j in range(n)]
    if n <= m:
        for i in range(n):
            if sum(a[i]) > 0:
                ones += 1
        if ones == n:
            print('Vivek')
        elif (ones - n) % 2 == 1:
            print('Ashish')
        else:
            print('Vivek')
    else:
        ones = row_s(a, n, m)
        if ones == m:
            print('Vivek')
        elif (ones - n) % 2 == 1:
            print('Ashish')
        else:
            print('Vivek')


for _ in range(int(input())):
    ones = 0
    n, m = [int(s) for s in input().split()]
    a = [[int(s) for s in input().split()] for j in range(n)]
    for i in range(n):
        if sum(a[i]) > 0:
            ones += 1
    if ones == min(n, m):
        print('Vivek')
    elif (ones - min(n, m)) % 2 == 1:
        print('Ashish')
    else:
        print('Vivek')


for _ in range(int(input())):
    ones = 0
    n, m = [int(s) for s in input().split()]
    a = [[int(s) for s in input().split()] for j in range(n)]
    for i in range(n):
        ones += sum(a[i])
    if ones >= min(n, m):
        print('Vivek')
    elif (ones - min(n, m)) % 2 == 1:
        print('Ashish')
    else:
        print('Vivek')


for _ in range(int(input())):
    ones = 0
    n, m = [int(s) for s in input().split()]
    a = [[int(s) for s in input().split()] for j in range(n)]
    for i in range(n):
        ones += sum(a[i])
    if ones >= min(n, m):
        print('Vivek')
    elif (ones - min(n, m)) % 2 == 1:
        print('Asish')
    else:
        print('Vivek')


def row_s(a, n, m):
    ans = 0
    for j in range(m):
        for i in range(n):
            if a[i][j] == 1:
                ans += 1
                break
    return ans

for _ in range(int(input())):
    ones = 0
    n, m = [int(s) for s in input().split()]
    a = [[int(s) for s in input().split()] for j in range(n)]
    if n <= m:
        for i in range(n):
            ones += sum(a[i])
        if ones == n:
            print('Vivek')
        elif (ones - n) % 2 == 1:
            print('Ashish')
        else:
            print('Vivek')
    else:
        ones = row_s(a, n, m)
        if ones == m:
            print('Vivek')
        elif (ones - m) % 2 == 1:
            print('Ashish')
        else:
            print('Vivek')


def row_s(a, n, m):
    ans = 0
    for j in range(m):
        for i in range(n):
            if a[i][j] == 1:
                ans += 1
                break
    return ans

for _ in range(int(input())):
    ones = 0
    n, m = [int(s) for s in input().split()]
    a = [[int(s) for s in input().split()] for j in range(n)]
    if n <= m:
        for i in range(n):
            ones += sum(a[i])
        if ones == n:
            print('Vivek')
        elif (ones - n) % 2 == 1:
            print('Ashish')
        else:
            print('Vivek')
    else:
        ones = row_s(a, n, m)
        if ones == m:
            print('Vivek')
        elif (ones - n) % 2 == 1:
            print('Ashish')
        else:
            print('Vivek')


def row_s(a, n, m):
    ans = 0
    for j in range(m):
        for i in range(n):
            if a[i][j] == 1:
                ans += 1
                break
    return ans

for _ in range(int(input())):
    ones = 0
    n, m = [int(s) for s in input().split()]
    a = [[int(s) for s in input().split()] for j in range(n)]
    row_ones = row_s(a, n, m)
    line_ones = 0
    for i in range(n):
        if sum(a[i]) > 0:
            line_ones += 1
    ones = min(m - row_ones, n - line_ones)
    if ones % 2 == 1:
        print('Ashish')
    else:
        print('Vivek')


t=int(input())
while t:
    n,m =map(int,input().split())
    mat=[list(map(int,input().split())) for _ in range(n)]

    r=[]
    c=[]
    winn=0
    for i in range(n):
        for j in range(m):
            if mat[i][j]==1:
                r.append(i)
                c.append(j)
    for i in range(n):
        for j in range(m):
            if i not in r and j not in c:
                winn+=1
                r.append(i)
                c.append(j)

    if winn%2==0:
        print("Vivek")
    else:
        print("Ashish")
    t-=1


for _ in range(int(input())):
    n, m = map(int, input().split())
    li = [[]]*n
    for i in range(n):
        li[i] = list(map(int, input().split()))
    for i in range(n):
        for j in range(m):
            if(li[i][j] == 1):
                for k in range(n):
                    if(li[k][j] == 0):
                        li[k][j] = -1
                for p in range(m):
                    if(li[i][p] == 0):
                        li[i][p] = -1
    ans = 0
    while(1):
        f = 1
        for i in range(n):
            for j in range(m):
                if(li[i][j] == 0):
                    if(ans): ans = 0
                    else: ans = 1
                    f = 0
                    for k in range(n):
                        li[k][j] = -1
                    for p in range(m):
                        li[i][p] = -1
        if(f):
            break
    if(ans): print("Ashish")
    else: print("Vivek")


for _ in range(int(input())):
    n,m=map(int,input().split())
    ans=0
    am=True
    b=[0 for _ in range(m)]
    p=m
    for _ in range(n):
        l=list(map(int,input().split()))
        for i in range(m):
            if b[i]==0:
                if l[i]==1:
                    b[i]=1
                    p-=1
        if p==0:
            am=False
            break
        if l.count(1)==0:
            ans+=1
    if ans%2==0:
        print("Vivek")
    else:
        print("Ashish")


for _ in range(int(input())):
    n,m=map(int,input().split())
    ans=0
    a=[]
    b=[0 for _ in range(m)]
    c=[0 for _ in range(n)]
    for j in range(n):
        l=list(map(int,input().split()))
        a.append(l)
        for i in range(m):
            if b[i]==0:
                if l[i]==1:
                    b[i]=1
        if 1 in l:
            c[j]=1
    ans=min(b.count(0),c.count(0))
    if ans%2==0:
        print("Vivek")
    else:
        print("Ashish")


t = int(input())
m,n = [int(d) for d in input().split()]
l = []
for i in range(m):
	row = [int(d) for d in input().split()]
	l.append(row)
row_count = [False]*m
col_count = [False]*n
for i in range(m):
	for j in range(n):
		if l[i][j] == 1:
			row_count[i] = True
			col_count[j] = True
row_c = 0
col_c = 0
for i in range(m):

	if row_count[i] == False:
		row_c += 1

for i in range(n):

	if col_count[i] == False:
		col_c += 1

a = min(row_c,col_c)
if a%2 == 0:
	print("Vivek")
else:
	print("Ashish")


t = int(input())
for _ in range(t):
	m,n = [int(d) for d in input().split()]
	l = []
	for i in range(m):
		row = [int(d) for d in input().split()]
		l.append(row)
	row_count = [False]*m
	col_count = [False]*n
	for i in range(m):
		for j in range(n):
			if l[i][j] == 1:
				row_count[i] = True
				col_count[j] = True
	row_c = 0
	col_c = 0
	for i in range(m):

		if row_count[i] == False:
			row_c += 1

	for i in range(n):

		if col_count[i] == False:
			col_c += 1

	a = min(row_c,col_c)
	if a%2 != 0:
		print("Vivek")
	else:
		print("Ashish")


t = int(input())
for _ in range(t):
	m,n = [int(d) for d in input().split()]
	l = []
	for i in range(m):
		row = [int(d) for d in input().split()]
		l.append(row)
	row_count = [False]*m
	col_count = [False]*n
	for i in range(m):
		for j in range(n):
			if l[i][j] == 1:
				row_count[i] = True
				col_count[j] = True
	row_c = 0
	col_c = 0
	for i in range(m):

		if row_count[i] == False:
			row_c += 1

	for i in range(n):

		if col_count[i] == False:
			col_c += 1

	a = min(row_c,col_c)
	if a%2 == 0:
		print("Vivek")
	else:
		print("Ashish")


t = int(input())

while(t != 0):
	t-=1
	n, m = [int(x) for x in input().split()]
	l = []
	for i in range(n):
		arr = list(map(int,input().split()))
		l.append(arr)

	c = [-1]*m
	r = [-1]*n

	for x in range(len(l)):
		for j in range(len(l[x])):
			if(l[x][j] == 1):
				c[j] = 1
				r[x] = 1
	# print(c , r)

	if(c.count(1) == m or r.count(1)== n):
		print("Vivek")
		continue

	else:
		y = 0
		for x in range(len(l)):
			if(r[x] == 1):
				continue
			for j in range(len(l[x])):
				if(c[j] == 1):
					continue
				else:
					y = 1 - y
					break

		if(y):
			print("Ashish")
		else:
			print("Vivek")


t = int(input())

while(t != 0):
	t-=1
	n, m = [int(x) for x in input().split()]
	l = []
	for i in range(n):
		arr = list(map(int,input().split()))
		l.append(arr)

	flag = 0

	for x in range(len(l)):
		if(sum(l[x]) == m):
			flag = 1
			break

	if(flag):
		print("Vivek")
		continue

	else:
		y = 0
		for x in range(len(l)):
			if(sum(l[x]) > 0):
				continue
			else:
				y = 1 - y

		if(y):
			print("Ashish")
		else:
			print("Vivek")


t = int(input())

while(t != 0):
	t-=1
	n, m = [int(x) for x in input().split()]
	l = []
	for i in range(n):
		arr = list(map(int,input().split()))
		l.append(arr)

	c = [-1]*m
	r = [-1]*n

	for x in range(len(l)):
		for j in range(len(l[x])):
			if(l[x][j] == 1):
				c[j] = 1
				r[x] = 1
	# print(c , r)

	if(c.count(1) == m or r.count(1)== n):
		print("Vivek")
		continue

	else:
		k = min(c.count(-1), r.count(-1))

		if(k%2 == 0):
			print("Vivek")
		else:
			print("Ashish")


t = int(input())

while(t != 0):
	t-=1
	n, m = [int(x) for x in input().split()]
	l = []
	for i in range(n):
		arr = list(map(int,input().split()))
		l.append(arr)

	c = [-1]*m
	r = [-1]*n

	for x in range(len(l)):
		for j in range(len(l[x])):
			if(l[x][j] == 1):
				c[j] = 1
				r[x] = 1
	# print(c , r)

	if(c.count(1) == m or r.count(1)== n):
		print("Vivek")
		continue

	else:
		y = 0
		for x in range(len(l)):
			if(r[x] == 1):
				continue
			for j in range(len(l[x])):
				if(c[j] == 1):
					continue
				else:
					y = 1 - y
					print(y)
					break

		if(y):
			print("Ashish")
		else:
			print("Vivek")


t = int(input())

while(t != 0):
	t-=1
	n, m = [int(x) for x in input().split()]
	l = []
	for i in range(n):
		arr = list(map(int,input().split()))
		l.append(arr)

	b = [-1 , -1 , -1]

	for x in range(len(l)):
		for j in range(len(l[x])):
			if(l[x][j] == 1):
				b[j] = 1

	if(b.count(1) == 3):
		print("Vivek")
		continue

	else:
		y = 0
		for x in range(len(l)):
			if(sum(l[x]) > 0):
				continue
			else:
				y = 1 - y

		if(y):
			print("Ashish")
		else:
			print("Vivek")


t = int(input())

while(t != 0):
	t-=1
	n, m = [int(x) for x in input().split()]
	l = []
	for i in range(n):
		arr = list(map(int,input().split()))
		l.append(arr)

	b = [-1]*m

	for x in range(len(l)):
		for j in range(len(l[x])):
			if(l[x][j] == 1):
				b[j] = 1

	if(b.count(1) == m):
		print("Vivek")
		continue

	else:
		y = 0
		for x in range(len(l)):
			if(sum(l[x]) > 0):
				continue
			else:
				y = 1 - y

		if(y):
			print("Ashish")
		else:
			print("Vivek")


z,zz=input,lambda:list(map(int,z().split()))
mod = 10**9 + 7
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
def lcd(xnum1,xnum2):
    return (xnum1*xnum2//gcd(xnum1,xnum2))
def prime(x):
        p=ceil(x**.5)+1
        for i in range(2,p):
            if x%i==0:
                return 0
        return 1

################################################################################

"""

led=(6,2,5,5,4,5,6,3,7,6)

vowel={'a':0,'e':0,'i':0,'o':0,'u':0}

color4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ]

"""

###########################---START-CODING---###############################################

n=int(z())

for _ in range(n):
    n,m=zz()
    ans=[]
    t=0
    for i in range(n):
        t+=zz().count(1)
    if max(n-t,0)%2==0:
        print('v')
    else:
        print('a')


z,zz=input,lambda:list(map(int,z().split()))
mod = 10**9 + 7
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
def lcd(xnum1,xnum2):
    return (xnum1*xnum2//gcd(xnum1,xnum2))
def prime(x):
        p=ceil(x**.5)+1
        for i in range(2,p):
            if x%i==0:
                return 0
        return 1

################################################################################

"""

led=(6,2,5,5,4,5,6,3,7,6)

vowel={'a':0,'e':0,'i':0,'o':0,'u':0}

color4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ]

"""

###########################---START-CODING---###############################################

n=int(z())

for _ in range(n):
    n,m=zz()
    ans=[]
    t=0
    for i in range(n):
        l=zz()
        ans.append(l)
        if l.count(1)<=0:
            t+=1

    if t==0:
        print('Vivek')
        continue
    p1=0
    for i in range(m):
        t1=0
        for j in range(n):
            if ans[j][i]==1:
                t1+=1
                break
        if t1==0:
            p1+=1

    t=min(t,p1)
    if t%2==0:print('Vivek')
    else:
        print('Ashish')


z,zz=input,lambda:list(map(int,z().split()))
mod = 10**9 + 7
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
def lcd(xnum1,xnum2):
    return (xnum1*xnum2//gcd(xnum1,xnum2))
def prime(x):
        p=ceil(x**.5)+1
        for i in range(2,p):
            if x%i==0:
                return 0
        return 1

################################################################################

"""

led=(6,2,5,5,4,5,6,3,7,6)

vowel={'a':0,'e':0,'i':0,'o':0,'u':0}

color4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OYGBIV",'ROYGBIV' ]

"""

###########################---START-CODING---###############################################

n=int(z())

for _ in range(n):
    n,m=zz()
    ans=[]
    t=0
    for i in range(n):
        t+=zz().count(1)
    if max(n-t,0)%2==0:
        print('Vivek')
    else:
        print('Ashish')


for t in range(int(input())):
	n, m = map(int, input().split())
	a = list()
	for _ in range(n):
		nums = list(map(int, input().split()))
		for v in nums:
			a.append(v)
	turn = 0
	for i in range(n*m):
		if a[i] != 0:
			continue
		if i == 0:
			if a[i] == a[i+1]:
				a[i] = 1
				turn += 1
		elif i == n*m-1:
			if a[i] == a[i-1]:
				a[i] = 1
				turn += 1
		else:
			if a[i] == a[i-1] and a[i] == a[i+1]:
				a[i] = 1
				turn += 1

	if turn%2 == 0:
		print("Vivek")
	else:
		print("Ashish")


for t in range(int(input())):
	n, m = map(int, input().split())
	a = list()
	for _ in range(n):
		nums = list(map(int, input().split()))
		for v in nums:
			a.append(v)
	turn = 0
	for i in range(n*m):
		if a[i] != 0:
			continue
		if i == 0:
			if a[i+1] == a[i+m] == 0:
				a[i] = 1
				turn += 1
		elif i == n*m-1:
			if a[i-1] == a[i-m] == 0:
				a[i] = 1
				turn += 1
		else:
			if i-m > -1:
				if i+m < n*m:
					if a[i-1] == a[i+1] == a[i+m] == a[i-m] == 0:
						a[i] = 1
						turn += 1
				else:
					if a[i-1] == a[i+1] == a[i-m] == 0:
						a[i] = 1
						turn += 1
			else:
				if i+m < n*m:
					if a[i-1] == a[i+1] == a[i+m] == 0:
						a[i] = 1
						turn += 1
				else:
					if a[i-1] == a[i+1] == 0:
						a[i] = 1
						turn += 1

	if turn%2 == 0:
		print("Vivek")
	else:
		print("Ashish")


def check(a):
	lc, c, b =0, 0, [0,0]
	for i in range(n):
		for j in range(m):
			if a[i][j] != 0:
				continue
			c = 0
			if i-1 > -1:
				if a[i-1][j] == 0:
					c += 1
				else:
					continue
			if i+1 < n:
				if a[i+1][j] == 0:
					c += 1
				else:
					continue

			if j-1 > -1:
				if a[i][j-1] == 0:
					c += 1
				else:
					continue

			if j+1 < m:
				if a[i][j+1] == 0:
					c += 1
				else:
					continue
			if c > lc:
				b = [i,j]
			lc = c
	if lc == 0:
		return 0
	return b
for t in range(int(input())):
	n, m = map(int, input().split())
	a = list()
	for _ in range(n):
		a.append(list(map(int, input().split())))
	turn = 0
	while check(a) != 0:
		c = check(a)
		a[c[0]][c[1]] = 1
		turn += 1

	if turn%2 == 0:
		print("Vivek")
	else:
		print("Ashish")


for t in range(int(input())):
	n, m = map(int, input().split())
	a = list()
	for _ in range(n):
		a.append(list(map(int, input().split())))

	r, c = 0, 0
	flag = False
	for i in range(m):
		counter = 0
		for j in range(n):
			if len(set(a[j])) == 1 and a[j][0] == 0 and not flag:
				r += 1
			if a[j][i] == 0:
				counter += 1
		flag = True
		if counter == n:
			c += 1
	if min(r,c)%2 == 0:
		print("Vivek")
	else:
		print("Ashish")


for _ in range(int(input())):
	n,m=map(int,input().split())
	ans=0
	a=[]
	r={i for i in range(n)}
	c={i for i in range(m)}
	for i in range(n):
		flag=0
		l=list(map(int,input().split()))
		for j in range(m):
			if l[j]==1:
				flag=1
				if j in c:
					c.remove(j)
		if flag==1:
			r.remove(i)
	ans=min(len(r),len(c))
	if ans%2==0:
		print("Vivek")
	else:
		print("Ashish")


for i in range(int(input())):
	n,m=map(int,input().split())
	ans=0
	a=[]
	for i in range(n):
		l=list(map(int,input().split()))
		ans+=l.count(0)
	if ans%2==0:
		print("Vivek")
	else:
		print("Ashish")


for _ in range(int(input())):
	n,m=map(int,input().split())
	ans=0
	a=[]
	r=set()
	c=set()
	for i in range(n):
		flag=0
		l=list(map(int,input().split()))
		for j in range(m):
			if l[j]==1:
				flag=1
				c.add(j)
		if flag==1:
			r.add(i)
	for i in range(n):
		if i not in r:
			if len(c)!=m:
				for j in range(m):
					if j not in c:
						ans+=1
						c.add(j)
						r.add(j)
						break
	if ans%2==0:
		print("Vivek")
	else:
		print("Ashish")


# The ideia of this code is that an element can only be changed to 1 if its
# row and columns only contains 0s, so, when it is changed to one, none of the
# elements on this column or row can be changed to 1, thus, it invalidates
# both the row and the colum.
#
# With that said, the ideia then is to count the number of rows and columns with
# zeros, and the minumum of those two are the number of plays that can be made.

# read number of test cases
testCases = int(input())

# apply logic for each test case
while testCases > 0:

    # read number of rows and columns
    row, column = list(map(int, input().split()))

    # allocate space for the grid
    grid = []
    for i in range(row):
        grid.append(list(map(int, input().split())))

    # count number of rows with only zeros
    rowZeros = 0
    for i in range(row):

        found = False
        for j in range(column):

            if grid[i][j] == 1:
                found = True
                break

        if found is False:
            rowZeros += 1

    # count number of columns with only zeros
    columnZeros = 0
    for j in range(column):

        found = False
        for i in range(row):

            if grid[i][j] == 1:
                found = True
                break

        if found is False:
            columnZeros += 1

    # get minimum of them
    minimum = min(rowZeros, columnZeros)

    # print response based on number of possible plays
    if minimum % 2 == 0:
        print('Vivek')
    else:
        print('Ashish')

    testCases -= 1


# The ideia of this code is that an element can only be changed to 1 if its
# row and columns only contains 0s, so, when it is changed to one, none of the
# elements on this column or row can be changed to 1, thus, it invalidates
# both the row and the colum.
#
# With that said, the ideia then is to count the number of rows and columns with
# zeros, and the minumum of those two are the number of plays that can be made.

# read number of test cases
testCases = int(input())

# apply logic for each test case
while testCases > 0:

    # read number of rows and columns
    row, column = list(map(int, input().split()))

    # allocate space for the grid
    grid = []
    for i in range(row):
        grid.append(list(map(int, input().split())))

    # count number of rows with only zeros
    rowZeros = 0
    for i in range(row):

        found = False
        for j in range(row):

            if grid[i][j] == 1:
                found = True
                break

        if found is False:
            rowZeros += 1

    # count number of columns with only zeros
    columnZeros = 0
    for j in range(row):

        found = False
        for i in range(row):

            if grid[i][j] == 1:
                found = True
                break

        if found is False:
            columnZeros += 1

    # get minimum of them
    minimum = min(rowZeros, columnZeros)

    print(minimum)

    # print response based on number of possible plays
    if minimum % 2 == 0:
        print('Vivek')
    else:
        print('Ashish')

    testCases -= 1


# The ideia of this code is that an element can only be changed to 1 if its
# row and columns only contains 0s, so, when it is changed to one, none of the
# elements on this column or row can be changed to 1, thus, it invalidates
# both the row and the colum.
#
# With that said, the ideia then is to count the number of rows and columns with
# zeros, and the minumum of those two are the number of plays that can be made.

# read number of test cases
testCases = int(input())

# apply logic for each test case
while testCases > 0:

    # read number of rows and columns
    row, column = list(map(int, input().split()))

    # allocate space for the grid
    grid = []
    for i in range(row):
        grid.append(list(map(int, input().split())))

    # count number of rows with only zeros
    rowZeros = 0
    for i in range(row):

        found = False
        for j in range(row):

            if grid[i][j] == 1:
                found = True
                break

        if found is False:
            rowZeros += 1

    # count number of columns with only zeros
    columnZeros = 0
    for j in range(row):

        found = False
        for i in range(row):

            if grid[i][j] == 1:
                found = True
                break

        if found is False:
            columnZeros += 1

    # get minimum of them
    minimum = min(rowZeros, columnZeros)

    # print response based on number of possible plays
    if minimum % 2 == 0:
        print('Vivek')
    else:
        print('Ashish')

    testCases -= 1


# The ideia of this code is that an element can only be changed to 1 if its
# row and columns only contains 0s, so, when it is changed to one, none of the
# elements on this column or row can be changed to 1, thus, it invalidates
# both the row and the colum.
#
# With that said, the ideia then is to count the number of rows and columns with
# zeros, and the minumum of those two are the number of plays that can be made.

# read number of test cases
testCases = int(input())

# apply logic for each test case
while testCases > 0:

    # read number of rows and columns
    row, column = list(map(int, input().split()))

    # allocate space for the grid
    grid = []
    for i in range(row):
        grid.append(list(map(int, input().split())))

    # count number of rows with only zeros
    rowZeros = 0
    for i in range(row):

        found = False
        for j in range(column):

            if grid[i][j] == 1:
                found = True
                break

        if found is False:
            rowZeros += 1

    # count number of columns with only zeros
    columnZeros = 0
    for j in range(row):

        found = False
        for i in range(column):

            if grid[i][j] == 1:
                found = True
                break

        if found is False:
            columnZeros += 1

    # get minimum of them
    minimum = min(rowZeros, columnZeros)

    # print response based on number of possible plays
    if minimum % 2 == 0:
        print('Vivek')
    else:
        print('Ashish')

    testCases -= 1


import queue
import math

t = int(input())

while (t):

	line = input().split()
	n,m = int(line[0]), int(line[1])
	a = []

	for i in range(n):
		a.append(input().split())

	cnt = 0

	for i in range(n):

		for j in range(m):

			if (a[i][j] == '0'):

				flag = True

				for k in range(n):
					a[k][j] = '-1'
					if (a[k][j] == '1'):
						flag = False
						break

				for k in range(m):
					a[i][k] = '-1'
					if (a[i][k] == '1'):
						flag = False
						break

				cnt += flag

	if (cnt % 2 == 0):
		print('Vivek')
	else:
		print('Ashish')

	t -= 1


import queue
import math

t = int(input())

while (t):

	line = input().split()
	n,m = int(line[0]), int(line[1])
	a = []

	for i in range(n):
		a.append(input().split())

	cnt = min(n,m)
	for i in range(min(n,m)):
		tmp = 0
		for j in range(m):
			if (a[i][j] == '1'):
				tmp = 1
		for j in range(n):
			if (a[j][i] == '1'):
				tmp = 1
		cnt -= tmp

	if (cnt % 2 == 0):
		print('Vivek')
	else:
		print('Ashish')

	t -= 1


import queue
import math

t = int(input())

while (t):

	line = input().split()
	n,m = int(line[0]), int(line[1])

	a = []

	for i in range(n):
		a.append(input().split())

	for i in range(n):
		for j in range(m):
			if (a[i][j] == '1'):
				for k in range(n):
					if (a[k][j] != '1'):
						a[k][j] = '-1'
				for k in range(m):
					if (a[i][k] != '1'):
						a[i][k] = '-1'

#	for i in range(n):
#		for j in range(m):
#			print(a[i][j],end=' ')
#		print()

	N,M = 0,0
	for i in range(n):
		mm = 0
		for j in range(m):
			if (a[i][j] == '0'):
				mm += 1
		M = max(M,mm)
		if (mm > 0):
			N += 1

	if (min(N,M) % 2 == 0):
		print('Vivek')
	else:
		print('Ashish')

	t -= 1


def transpose(A,N,M):
    B = [[0 for x in range(M)] for y in range(N)]
    for i in range(N):
        for j in range(M):
            B[i][j] = A[j][i]

    return B

t = int(input())
for _ in range(t):
    l = []
    n,m = map(int,input().split(' '))
    for _ in range(n):
        arr = [int(num) for num in input().split(' ')]
        l.append(arr)

    arr2 = transpose(l,m,n)
    for item in l:
        if 1 in item:
            n = n - 1
    for item in arr2:
        if 1 in item:
            m = m - 1
    x = min(n,m)
    if x%2==0:
        print('Vivek')
    else:
        print('Ashish')


def transpose(A,N,M):
    B = [[0 for x in range(M)] for y in range(N)]
    for i in range(N):
        for j in range(M):
            B[i][j] = A[j][i]

    return B

t = int(input())
for _ in range(t):
    l = []
    n,m = map(int,input().split(' '))
    for _ in range(n):
        arr = [int(num) for num in input().split(' ')]
        l.append(arr)

    for item in l:
        if 1 in item:
            n = n - 1

    arr2 = transpose(l,m,n)
    for item in arr2:
        if 1 in item:
            m = m - 1
    x = min(n,m)
    if x%2==0:
        print('Vivek')
    else:
        print('Ashish')


def transpose(A,N,M):
    B = [[0 for x in range(M)] for y in range(N)]
    for i in range(N):
        for j in range(M):
            B[i][j] = A[j][i]

    return B

t = int(input())
for _ in range(t):
    l = []
    n,m = map(int,input().split(' '))
    for _ in range(n):
        arr = [int(num) for num in input().split(' ')]
        l.append(arr)

    for item in l:
        if 1 in item:
            n = n - 1

    arr2 = transpose(l,n,m)
    for item in arr2:
        if 1 in item:
            m = m - 1
    x = min(n,m)
    if x%2==0:
        print('Vivek')
    else:
        print('Ashish')


T = int(input())
while T > 0:
    n,m = map(int, input().split())
    row, col = set(), set()
    for i in range(n):
        arr = list(map(int, input().split()))
        for j in range(m):
            if arr[j] == 1:
                row.add(i)
                col.add(j)
    x = min(n-len(row), m-len(col))
    if x%2 == 1:
        print('Ashish')
    else:
        print('Vivek')

    T -= 1


T = int(input())
directions = [[0,1],[0,-1],[1,0],[-1,0]]
while T > 0:
    n,m = map(int, input().split())
    total = 0
    visited = [[False for i in range(m)] for j in range(n)]
    matrix = []
    for i in range(n):
        row = list(map(int, input().split()))
        matrix.append(row)
    for i in range(n):
        for j in range(m):
            if matrix[i][j] == 1:
                visited[i][j] = True
                for direction in directions:
                    x, y = i+direction[0], j+direction[1]
                    if x >=0 and x < n and y >= 0 and y < m:
                        visited[x][y] = True
    for i in range(n):
        for j in range(m):
            if visited[i][j] is False:
                total += 1
                visited[i][j] = True
                for direction in directions:
                    x, y = i+direction[0], j+direction[1]
                    if x >=0 and x < n and y >= 0 and y < m:
                        visited[x][y] = True
    if total%2 == 1:
        print('Ashish')
    else:
        print('Vivek')
    T -= 1


T = int(input())
while T > 0:
    n,m = map(int, input().split())
    row, col = set(), set()
    for i in range(n):
        arr = list(map(int, input().split()))
        for j in range(m):
            if arr[j] == 1:
                row.add(i)
                col.add(j)
    x = min(n-row, m-col)
    if x%2 == 1:
        print('Ashish')
    else:
        print('vivek')

    T -= 1


T = int(input())
directions = [[0,1],[0,-1],[1,0],[-1,0]]
def dfs(matrix, visited,n,m):
    for i in range(n):
        for j in range(m):
            if visited[i][j] is False:
                visited[i][j] = True
                change = []
                for direction in directions:
                    x, y = i+direction[0],j+direction[1]
                    if x >=0 and x < n and y >=0 and y < m and visited[x][y] is False:
                        change.append([x,y])
                        visited[x][y] = True
                temp = dfs(matrix, visited, n, m)
                visited[i][j] = False
                for pos in change:
                    visited[pos[0]][pos[1]] = False
                if not temp:
                    return True
    return False

while T > 0:
    n,m = map(int, input().split())
    total = 0
    visited = [[False for i in range(m)] for j in range(n)]
    matrix = []
    for i in range(n):
        row = list(map(int, input().split()))
        matrix.append(row)
    for i in range(n):
        for j in range(m):
            if matrix[i][j] == 1:
                visited[i][j] = True
                for direction in directions:
                    x, y = i+direction[0],j+direction[1]
                    if x >= 0 and x < n and y >= 0 and y < m:
                        visited[x][y] = True
    res = dfs(matrix, visited, n, m)
    if res is True:
        print('Ashish')
    else:
        print('Vivek')

    T -= 1


T = int(input())
directions = [[0,1],[0,-1],[1,0],[-1,0]]
def dfs(matrix, visited,n,m):
    for i in range(n):
        for j in range(m):
            if visited[i][j] is False:
                visited[i][j] = True
                change = []
                for direction in directions:
                    x, y = i+direction[0],j+direction[1]
                    if x >=0 and x < n and y >=0 and y < n and matrix[x][y] = 0:
                        change.append([x,y])
                        visited[x][y] = True
                temp = dfs(matrix, visited, n, m)
                visited[i][j] = False
                for pos in change:
                    visietd[pos[0]][pos[1]] = False
                if not temp:
                    return True
    return False

while T > 0:
    n,m = map(int, input().split())
    visited = [[False for i in range(m)] for j in range(n)]
    matrix = []
    for i in range(n):
        row = list(map(int, input().split()))
        matrix.append(row)
    for i in range(n):
        for j in range(m):
            if matrix[i][j] == 1:
                visited[i][j] = True
                for diretcion in directions:
                    x, y = i+direction[0],j+direction[1]
                    if x >= 0 and x < n and y >= 0 and y < m:
                        visited[x][y] = True
    res = dfs(matrix, visited, n, m)
    if res is True:
        print('Ashish')
    else:
        print('Vivek')

    T -= 1


q=int(input())
for _ in range(q):
    n,m = map(int, input().split())
    a = 0
    live = [True] * m
    for _ in range(n):
        dat = list(map(int, input().split()))
        for i in range(m):
            if dat[i] == 1:
                live[i] = False
        a += 1 if dat.count(1) == 0 else 0

    b = live.count(True)
    a = min(a,b)

    print("Vivek" if a%2 == 0 else "Ashish")


q=int(input())
for _ in range(q):
    n,m = map(int, input().split())
    a = 0
    live = [True] * m
    for _ in range(n):
        dat = list(map(int, input().split()))
        for i in range(m):
            if dat[i] == 1:
                live[i] = False
        a += 1 if dat.count(1) == 0 else 0

    b = live.count(False)

    print("Vivek" if a%2 == 0  or b % 2 == 0 else "Ashish")


q=int(input())
for _ in range(q):
    n,m = map(int, input().split())
    a = 0
    for _ in range(n):
        s = input()
        if s.count("1") == 0:
            a += 1
    print("Vivek" if a%2 == 0 else "Ashish")


q=int(input())
for _ in range(q):
    n,m = map(int, input().split())
    a = 0
    live = [True] * m
    for _ in range(n):
        dat = list(map(int, input().split()))
        for i in range(m):
            if dat[i] == 1:
                live[i] = False
        a += 1 if dat.count(1) == 0 else 0

    b = live.count(False)
    a = min(a,b)

    print("Vivek" if a%2 == 0 else "Ashish")


for i1 in range(int(input())):
    n,m=map(int,input().split())
    a=[]
    for i in range(n):
        l=list(map(int,input().split()))
        a.append(l)
    #print(a)

    for i in range(n):
        for j in range(m):
            if a[i][j]==1:
                for i2 in range(n):
                    if a[i2][j]==0:
                        a[i2][j]=2
                for j2 in range(m):
                    if a[i][j2]==0:
                        a[i][j2]=2

    #print('New',a)
    track=0
    for i in range(n):
        for j in range(m):
            if a[i][j]==0:
                for i2 in range(n):
                    if a[i2][j]==0:
                        a[i2][j]=1
                for j2 in range(m):
                    if a[i][j2]==0:
                        a[i][j2]=1
                track+=1
                #print('NEw matrix',a)

    #print('Track',track)
    if track%2==0:
        print('Vivek')
    else:
        print('Ashish')


for i1 in range(int(input())):
    n,m=map(int,input().split())
    rows=[]
    columns=[]
    arr=[]
    for i in range(n):
        l=list(map(int,input().split()))
        arr.append(l)
    for i in range(n):
        for j in range(m):
            if arr[i][j]==1:
                rows.append(i)
                columns.append(j)

    rows=list(set(rows))
    columns=list(set(columns))
    r=n-len(rows)
    c=m-len(columns)
    ans=min(r,c)
    if ans%2==0:
        print('Vivek')
    else:
        print('Ashish')


for i1 in range(int(input())):
    n,m=map(int,input().split())
    rows=[]
    columns=[]
    arr=[]
    for i in range(n):
        l=list(map(int,input().split()))
        arr.append(l)
    for i in range(n):
        for j in range(m):
            if arr[i][j]==1:
                rows.append(i)
                columns.append(j)

    rows=list(set(rows))
    columns=list(set(columns))
    r=len(rows)
    c=len(columns)
    ans=min(r,c)
    if ans%2==0:
        print('Vivek')
    else:
        print('Ashish')


from sys import stdin

def readline():
    return stdin.readline()

tests = int(readline())

def solve(n, m, arr):
    index = 0
    r = []
    l = []
    for i in range(0, n):
        for j in range(0, m):
            if arr[i][j] == 1:
                r.append(j)
                l.append(i)

    for i in range(0, n):
        for j in range(0, m):
            if j not in r and i not in l:
                r.append(j)
                l.append(i)
                index += 1
                break

    if index % 2 == 0:
        return 'Vivek'
    return 'Ashish'

for t in range(0, tests):
    #s = readline().rstrip("\n")
    n, m = list(map(int, readline().rstrip("\n").split(' ')))
    arr = []
    for i in range(0, n):
        arr.append(list(map(int, readline().split(' '))))

    print(solve(n, m, arr))


from sys import stdin

def readline():
    return stdin.readline()

tests = int(readline())

def solve(n, m, arr):
    index = 0
    r = []
    l = []
    for i in range(0, n):
        for j in range(0, m):
            if arr[i][j] == 1:
                r.append(j)
                l.append(i)

    for i in range(0, n):
        for j in range(0, m):
            if j not in r and i not in l:
                index += 1
                break

    if index % 2 == 0:
        return 'Vivek'
    return 'Ashish'

for t in range(0, tests):
    #s = readline().rstrip("\n")
    n, m = list(map(int, readline().rstrip("\n").split(' ')))
    arr = []
    for i in range(0, n):
        arr.append(list(map(int, readline().split(' '))))

    print(solve(n, m, arr))


from sys import stdin

def readline():
    return stdin.readline()

tests = int(readline())

def solve(n, m, arr):
    index = 0
    for i in range(0, n):
        f = True
        for j in range(0, m):
            if arr[i][j] == 1:
                f = False
                break
        if f:
            index += 1

    if index % 2 == 0:
        return 'Vivek'
    return 'Ashish'

for t in range(0, tests):
    #s = readline().rstrip("\n")
    n, m = list(map(int, readline().rstrip("\n").split(' ')))
    arr = []
    for i in range(0, n):
        arr.append(list(map(int, readline().split(' '))))

    print(solve(n, m, arr))


t=int(input())
while(t):
	n,m=map(int,input().split())
	s=[]
	for i in range(n):
		s.append(list(map(int,input().split())))
	k=0
	for i in s:
		k+=i.count(1)
	l=min(m,n)
	l=l-k
	if(l%2==1):
		print("Ashish")
	else:
		print("Vivek")
	t-=1


t=int(input())
while(t):
	n,m=map(int,input().split())
	s=[]
	for i in range(n):
		s.append(list(map(int,input().split())))
	r=[]
	c=[]
	for i in range(n):
		for j in range(m):
			if(s[i][j]==1):
				r.append(i)
				c.append(j)
	#print(len(set(r)),len(set(c)))
	n=n-len(set(r))
	m=m-len(set(c))
	l=min(n,m)
	#print(k,l)
	if(l%2==1):
		print("Ashish")
	else:
		print("Vivek")
	t-=1


t=int(input())
while(t):
	n,m=map(int,input().split())
	s=[]
	for i in range(n):
		s.append(list(map(int,input().split())))
	l=min(n,m)
	if(l==m and n!=m):
		rez = [[s[j][i] for j in range(len(s))] for i in range(len(s[0]))]
		s=rez
	k=0
	for i in s:
		#print(i)
		if 1 in i:
			k+=1
	l=l-k
	#print(k,l)
	if(l%2==1):
		print("Ashish")
	else:
		print("Vivek")
	t-=1


import sys
input = sys.stdin.buffer.readline
a = int(input())
for x in range(a):
    b,c = map(int,input().split())
    j = 0
    k = 0
    f = []
    for y in range(b):
        f.append(list(map(int,input().split())))
    h = "Vivek"
    while(j < b and k < c):
        if f[j][k] == 1:
            if j < b:
                j += 1
            if k < c:
                k += 1
        elif 1 in f[j]:
            if j < b:
                j += 1
        elif 1 not in f[j]:
            r = 0
            for z in range(b):
                if f[z][k] == 0:
                    r += 1
                else:
                    if k < c:
                        k += 1
                    break
            if r == b:
                if j < b:
                    j += 1
                if k < c:
                    k += 1
                if h == "Vivek":
                    h = "Ashish"
                else:
                    h = "Vivek"

    print(h)


import sys
input = sys.stdin.buffer.readline
a = int(input())
for x in range(a):
    b,c = map(int,input().split())
    j = 0
    k = 0
    f = []
    for y in range(b):
        f.append(list(map(int,input().split())))
    h = "Vivek"
    while(j < b and k < c):
        if f[j][k] == 1:
            if j < b:
                j += 1
            if k < c:
                k += 1
        elif 1 in f[j]:
            if j < b:
                j += 1
        elif 1 not in f[j]:
            r = 0
            for z in range(b):
                if f[z][j] == 0:
                    r += 1
                else:
                    if k < c:
                        k += 1
                    break
            if r == b:
                if j < b:
                    j += 1
                if k < c:
                    k += 1
                if h == "Vivek":
                    h = "Ashish"
                else:
                    h = "Vivek"

    print(h)


import sys
input = sys.stdin.buffer.readline
a = int(input())
for x in range(a):
    b,c = map(int,input().split())
    t = []
    k = 0
    for y in range(b):
        j = list(map(int,input().split()))
        k += j.count(0)
        t.append(j)
    if k%2 != 0:
        print("Ashish")
    else:
        print("Vivek")


import sys
input = sys.stdin.buffer.readline
a = int(input())
for x in range(a):
    b,c = map(int,input().split())
    j = 0
    k = 0
    f = []
    for y in range(b):
        f.append(list(map(int,input().split())))
    h = "Vivek"
    while(j <= b-1 and k <= c-1):
        if f[j][k] == 1:
            j += 1
            k += 1
        elif 1 in f[j]:
            j += 1
        elif 1 not in f[j]:
            r = 0
            for z in range(b):
                if f[j][z] == 0:
                    r += 1
                else:
                    k += 1
                    break
            if r == b:
                j += 1
                k += 1
                if h == "Vivek":
                    h = "Ashish"
                else:
                    h = "Vivek"

    print(h)


import sys
input = sys.stdin.buffer.readline
a = int(input())
for x in range(a):
    b,c = map(int,input().split())
    j = 0
    k = 0
    f = []
    for y in range(b):
        f.append(list(map(int,input().split())))
    h = "Vivek"
    while(j <= b-1 and k <= c-1):
        if f[j][k] == 1:
            if j < b:
                j += 1
            if k < c:
                k += 1
        elif 1 in f[j]:
            if j < b:
                j += 1
        elif 1 not in f[j]:
            r = 0
            for z in range(b):
                if f[j][z] == 0:
                    r += 1
                else:
                    if k < c:
                        k += 1
                    break
            if r == b:
                if j < b:
                    j += 1
                if k < c:
                    k += 1
                if h == "Vivek":
                    h = "Ashish"
                else:
                    h = "Vivek"

    print(h)


for i in range(int(input())):
    n,m=map(int,input().split())
    fr,fc=n,set([i for i in range(m)])
    for i in range(n):
        r=input().split()
        h1=0
        for i in range(m):
            if r[i]=="1":
                h1=1
                if i in fc:
                    fc.remove(i)
        fr-=h1
    print("Ashish" if min(fr,len(fc))&1 else "Vivek")


for i in range(int(input())):
    n,m=map(int,input().split())
    fr,fc=n,set([i for i in range(m)])
    for i in range(n):
        r=input().split()
        h1=0
        for i in range(m):
            if r[i]=="1":
                h1=1
                if i in fc:
                    fc.remove(i)
        fr-=h1
    print(min(fr,len(fc)))
    print("Ashish" if min(fr,len(fc))&1 else "Vivek")