#include <stdio.h>
#include <math.h>

int winning(int n, int k);
int expmod(long long int a, int b, int m);
const int mod = 1000000007;

int main () {
  int t;
  int n;
  int k;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    scanf("%d %d", &n, &k);
    printf("%d\n", winning(n, k));
  }
}

int winning (int n, int k) {
  if (k == 0) {
    return 1;
  }
  if (n % 2 == 0) {
    long long int result = expmod(2, n*(k-1), mod) + (expmod(2, n-1, mod)-1)*winning(n, k-1);
    return result % mod;
  }
  else {
    long long int result = (expmod(2, n-1, mod)+1)*winning(n, k-1);
    return result % mod;
  }
}

int expmod(long long int a, int b, int m)
{
	int res = 1;
	a = a % m;

	if (a == 0) return 0;

	while (b > 0)
	{
		if (b & 1)
			res = (res*a) % m;

		b = b>>1;
		a = (a*a) % m;
	}
	return res;
}


#include <stdio.h>
#include <ctype.h>

// Program de Mircea Rebengiuc
// inceput pe 2021.08.09

#define MOD 1000000007
#define MAXN 100000
#define MAXK 100000

int p2[MAXK + 1];

static inline int multmod( int a, int b ){
  return (((long long)a) * b) % MOD;
}

static inline int addmod( int a, int b ){
  return (a + b) % MOD;
}

// chestii invmod
static inline int myExp( int a, int n ){
  int acc = 1;

  while( n > 0 ){
    if( n & 1 )
      acc = multmod(acc, a);
    a = multmod(a, a);
    n /= 2;
  }

  return acc;
}

static inline int inv( int x ){
  return myExp(x, MOD - 2);
}

int main(){
  int t, n, k, i, big_num, comb, x, answer;

  p2[0] = 1;
  for( i = 1 ; i <= MAXK ; i++ )
    p2[i] = (2 * p2[i - 1]) % MOD;// nu tb sa fac long long ca nu 2 * MOD nu da overflow

  for( scanf("%d", &t) ; t-- ; ){
    scanf("%d%d", &n, &k);

    // calculam big_num
    big_num = 0;
    comb = 1;
    for( i = 0 ; i < n ; i += 2 ){
      big_num = addmod(big_num, comb);
      comb = multmod(comb, multmod(n - i, n - i - 1));
      comb = multmod(comb, multmod(inv(i + 1), inv(i + 2)));
    }

    // simulam
    x = 1;
    answer = 0;// scadem din total ca conditia este >=
    for( i = 0 ; i < k ; i++ ){
      answer = addmod(answer, (1 ^ (n & 1)) * multmod(x, p2[k - i - 1])) % MOD;
      x = multmod(x, (n & 1) + big_num);
    }
    answer = addmod(answer, x);

    printf("%d\n", answer);
  }

  return 0;
}


#include <stdio.h>
#include <ctype.h>

// Program de Mircea Rebengiuc
// inceput pe 2021.08.09

#define MOD 1000000007
#define MAXN 200000
#define MAXK 200000

int p2[MAXK + 1];

static inline int multmod( int a, int b ){
  return (((long long)a) * b) % MOD;
}

static inline int addmod( int a, int b ){
  return (a + b) % MOD;
}

// chestii invmod
static inline int myExp( int a, int n ){
  int acc = 1;

  while( n > 0 ){
    if( n & 1 )
      acc = multmod(acc, a);
    a = multmod(a, a);
    n /= 2;
  }

  return acc;
}

static inline int inv( int x ){
  return myExp(x, MOD - 2);
}

int main(){
  int t, n, k, i, big_num, comb, x, answer;

  p2[0] = 1;
  for( i = 1 ; i <= MAXK ; i++ )
    p2[i] = (2 * p2[i - 1]) % MOD;// nu tb sa fac long long ca 2 * MOD nu da overflow

  for( scanf("%d", &t) ; t-- ; ){
    scanf("%d%d", &n, &k);

    // calculam big_num
    big_num = 0;
    comb = 1;
    for( i = 0 ; i < n ; i += 2 ){
      big_num = addmod(big_num, comb);
      comb = multmod(comb, multmod(n - i, n - i - 1));
      comb = multmod(comb, multmod(inv(i + 1), inv(i + 2)));
    }

    // simulam
    x = 1;
    answer = 0;
    for( i = 0 ; i < k ; i++ ){
      answer = addmod(answer, (1 ^ (n & 1)) * multmod(x, p2[k - i - 1]));
      x = multmod(x, (n & 1) + big_num);
    }
    answer = addmod(answer, x);// ca semnul este >=

    printf("%d\n", answer);
  }

  return 0;
}


#include <stdio.h>

#define MD	1000000007

long long power(long long a, int k) {
	long long p = 1;

	while (k) {
		if (k & 1)
			p = p * a % MD;
		a = a * a % MD;
		k >>= 1;
	}
	return p;
}

int main() {
	int t;

	scanf("%d", &t);
	while (t--) {
		int n, k, i, ans;

		scanf("%d%d", &n, &k);
		if (k == 0)
			printf("1\n");
		else if (n % 2 == 1)
			printf("%lld\n", power(power(2, n - 1) + 1, k));
		else {
			ans = power(power(2, n - 1) - 1, n);
			for (i = 0; i < k; i++)
				ans = (ans + power(power(2, n - 1) - 1, i) * power(power(2, n), k - 1 - i)) % MD;
			printf("%d\n", ans);
		}
	}
	return 0;
}


#pragma c11 on

#include<stdio.h>
#include<stdbool.h>
#include<limits.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define MOD (int)(1e9+7)
typedef enum colorType{
    white, green, red, blue, orange ,yellow
}colorType;

typedef struct treeNode{
    colorType color;
    struct treeNode* previous;
    struct treeNode* next;
}treeNode;
typedef struct tree{
    treeNode * root;
    int size;
}tree;
void makePerfectTree(int *t,int*k,treeNode* node){
    if(*t<*k){
        node->previous=calloc(1,sizeof(treeNode));
        node->next=calloc(1,sizeof(treeNode));
        (*t)++;
        makePerfectTree(t,k,node->previous);
        makePerfectTree(t,k,node->next);
    }
}

long long quickPow(long long n, long long powers) {
    long long res = 1;
    while (powers > 0) {
        if (powers & 1)
            res =res * n%MOD;
        n = n*n%MOD;
        powers >>= 1;
    }
    return res;
}
int main(void){
    int k;
    scanf("%d",&k);
    /*tree * tree1=(tree*)calloc(1,sizeof(tree));
    tree1->root=calloc(1,sizeof(treeNode));
    int t=1;
    makePerfectTree(&t,&k,tree1->root);
    //forget the idiot tree;
*/
    printf("%lld",6* quickPow(4, ((1<<k)-2))%MOD);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

#define MOD_NUMBER 1000000007

unsigned long long modpow(int n, unsigned long long index) {
    unsigned long long nn = n;
    unsigned long long ans = 1;
    while (index) {
        if (index & 1) {
            ans *= nn;
            ans %= MOD_NUMBER;
        }
        nn *= nn;
        nn %= MOD_NUMBER;
        index >>= 1;
    }

    return ans;
}

int run() {
    int n;
    scanf("%d", &n);
    long long a = (6*modpow(4, (1<<n) - 2))%MOD_NUMBER;
    printf("%lld\n", a);
    return 0;
}

int main(int argc, char* argv[]) {
    int n = 1;
    for (int i = 0; i < n; ++i) {
        run();
    }
    return 0;
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define DEBUG(x); printf("%d------\n",x);
#define ll long long
#define M 1000000007
ll power(ll a,ll b){
    if(b==0)return 1;
    ll ans=power(a,b/2)%M;
    if(b%2==0)return ans*ans%M;
    else return ans*ans*a%M;
}
int main(){
	int n;
	scanf("%d",&n);
	ll ans=6,start=1;
// 	n--;
	if(n>0){
	   // start*=2;
	    ans=ans*power(4,power(2,n)-2)%M;
	   // DEBUG(ans);
	   // n--;
	}
	printf("%lld",ans);
	return 0;
}


#include<stdio.h>
int main()
{
    int T,c[4],ans=0;

    scanf("%d",&T);
    for(int i=1;i<=T;i++){
        scanf("%d %d %d %d",c[0],c[1],c[2],c[3]);
        for(int j=0;j<4;j++){
            if(c[j]==0){
                ans++;
            }

        }
        if(ans==4) printf("0\n");

        else if(ans==3) printf("1\n");
        else if(ans==2) printf("1\n");
        else if(ans==1) printf("1\n");
        else printf("2\n");
    }

return 0;
}


#include<stdio.h>
int main()
{
    int T;
    int c[4];

    scanf("%d",&T);
    for(int i=1;i<=T;i++){printf("t");
    	for(int t=0;t<4;t++){
        scanf("%d",&c[t]);
    		}
    		int ans = 0;
        for(int j=0;j<4;j++){
            if(c[j]==0){
                ans++;
            }

        }
        if(ans==4) printf("0\n");

        else if(ans==3) printf("1\n");
        else if(ans==2) printf("1\n");
        else if(ans==1) printf("1\n");
        else printf("2\n");
    }

return 0;
}


#include<stdio.h>
int main()
{
    int Tcase;
    int c[4];

    scanf("%d",&T);
    for(int i=1;i<=Tcase;i++){
    	for(int t=0;t<4;t++){
        scanf("%d",&c[t]);
    		}
    		int ans = 0;
        for(int j=0;j<4;j++){
            if(c[j]==0){
                ans++;
            }

        }
        if(ans==4) printf("0\n");

        else if(ans==3) printf("1\n");
        else if(ans==2) printf("1\n");
        else if(ans==1) printf("1\n");
        else printf("2\n");
    }

return 0;
}


#include<stdio.h>
int main(){
    int i,test,sum;
    int a[2]={0},b[2]={0};
    scanf("%d",&test);
    while(test--){
        sum=0;
        for(i=0;i<2;i++){
            scanf("%d",&a[i]);
        }
        for(i=0;i<2;i++){
            scanf("%d",&b[i]);
        }
        for(i=0;i<2;i++){
            sum=a[i]+b[i]+sum;
        }
		printf("%d\t",sum);
        if(sum==0)
            printf("0\n");
        else if(sum>0&&sum<4)
                  printf("1\n");
        else if(sum==4)
                  printf("2\n");
    }
    return 0;
}


#include <stdio.h>
int main()
{
    int t;
    scanf("%d", &t);
    while(t--){
        int a,b,c,d,e;
        scanf("%d%d", &a,&b);
        scanf("%d%d", &c,&d);
        e=a+b+c+d;
        if(e==1){
            printf("1\n");
        }
        else if(e==2){
            printf("1\n");
        }
        else if(e==3){
            printf("2\n");
        }
        else{
            printf("%d\n", e/2);
        }
    }

    return 0;
}


#include<stdio.h>
int main()
{
    int a,b,c,d,p,q,t;
    scanf("%d",&t);
    while(t--){
    scanf("%d %d\n",&a,&b);
    scanf("%d %d\n",&c,&d);
    if(a+b+c+d==4){
        printf("2\n");
    }
    else if(a+b+c+d==0){
        printf("1\n");
    }
    else{
        printf("0\n");
    }
    }
    return 0;
}


#include<stdio.h>
int main()
{
    int a,b,c,d,p,q,t;
    scanf("%d",&t)
    while(t--){
    scanf("%d %d\n",&a,&b);
    scanf("%d %d\n",&c,&d);
    if(a+b+c+d==2){
        printf("2\n");
    }
    else if(a+b+c+d==0){
        printf("1\n");
    }
    else{
        printf("0\n");
    }
    }
    return 0;
}


#include <stdio.h>
int main()
{
    int t; scanf("%d",&t);
    int a[2][2];
    while(t--) {
        for(int i=0;i<2;i++)
            for(int j=0;j<2;j++) {scanf("%d",&a[i][j]); if(a[i][j]) c++;}

        if(c==0) printf("0\n");
        else if(c==4) printf("2\n");
        else printf("1\n");
    }

}


#include<stdio.h>
int main()
{
    int t,i,a[10],j;

    scanf("%d",&t);
    for(i=1;i<=t;i++)
    {
        int count=0;
        for(j=0;j<4;j++)
        {
            scanf("%d",&a[j]);
             if(a[j]==1)
                count++;
        }
    printf("%d\n",count/2);

    }
    return 0;
}


#include <stdio.h>

int main()
{
    int t,i,j,grass;
    scanf("%d",&t);
    int field[2][2];
    while (t!=0)
    {
        grass = 0;
    for (i=0;i<2;i++)
    {
        for (j=0;j<2;j++)
        {
        scanf("%d",&field[i][j]);
        if (field[i][j]==1)
        grass++;
        }
    }
    t--;
    if (grass==0)
    printf("%d",0);
    else if (grass ==4)
    printf("%d",2);
    else
    printf("%d",1);
    }
    return 0;
}


#include<stdio.h>
int main()
{
   int n,row,colum,sum=0,i;
scanf("%d",&n);

while(n--)
{
  for(row=1;row<=2;row++)
  {
    for(colum=1;colum<=2;colum++)
  {
  scanf("%d",&i);
  sum=sum+i;
  }
  }
if(sum==0)
    printf("0\n");
if(sum==1||sum==2)
    printf("1\n");
if(sum==3||sum==4)
    printf("2\n");
}
return 0;
}


#include <stdio.h>

int main(){
	int tc;
	scanf("%d", &tc);

	for(int i = 0; i < tc; i++){
		int x1, x2, y1, y2;
		scanf("%d %d", &x1, &x2);
		scanf("%d %d", &y1, &y2);

		// X1 X2
		// Y1 Y2

		int sum = x1 + x2 + y1 + y2;

		if(sum == 0){
			puts("0");
		}
		else{
			sum -= 2;
			if(sum <= 0){
				puts("1");
			}
			else{
				sum -= 2;
				puts("2");
			}
		}

	}

	return 0;
}


#include<stdio.h>

int mai(){
	int x;
	int ctr= 0 ;
	for(int i = 0 ; i<4 ; i++){
		scanf("%d" , &x);
		if(x==1){
			ctr++;
		}
	}
	if(ctr ==0){
		printf("0");
		return
	}
	if(ctr == 1 ||ctr==2 || ctr ==3){
		printf("1");
		return ;
	}
	if (ctr ==4){
		printf("2");
		return ;

	}
	return 0 ;
}

int main(){
	int t ;
	scanf("%d" , &t);
	for(int i = 0 ; i<t ; i++){
		mai();}
}


#include<stdio.h>

void mai(){
	int x;
	int ctr= 0 ;
	for(int i = 0 ; i<4 ; i++){
		scanf("%d" , &x);
		if(x==1){
			ctr++;
		}
	}
	if(ctr ==0){
		printf("0");
		return ;
	}
	if(ctr == 1 ||ctr==2 || ctr ==3){
		printf("1");
		return ;
	}
	if (ctr ==4){
		printf("2");
		return ;

	}
	return  ;
}

int main(){
	int t ;
	scanf("%d" , &t);
	for(int i = 0 ; i<t ; i++){
		mai();
	}
}


#include<stdio.h>

void main(){
    unsigned short t;
    scanf("%hu",&t);
    while(t--){
        unsigned register short count=0;
        for(unsigned register short i=0; i<4; i++){
            unsigned short n;
            scanf("%hu",&n);
            count+=n;
        }
        printf("%hu\n",(!count)?0:(count>2)?2:1);
    }
}


#include <stdio.h>
int main(){
    int t;
    scanf("%d", &t);
    while(t--){
        int x[4];
        for(int i = 0; i < 4; i++){
            scanf("%d", &x[i]);
        }
        int sum = x[0] + x[2];
        printf("%d\n", sum);
    }

    return 0;
}


 #include <stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    for(int i=0;i<t;i++){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);

    if((a+b+c+d)==0){
        printf("0");
    }
    else if ((a+b+c+d)==4){
        printf("2");
    }
    else {
        printf("1");
    }
    }
    return 0;
    }


#include<stdio.h>
#include <string.h>
int main()
{
int t;
scanf("%d", &t);
for(int i=0;i<t;i++){
 {
int a[100][100], n = 0;
 for (int i = 0; i < 2; i++)
  {
  for (int j = 0; j < 2; j++)
{
{ scanf("%d", &a[i][j]);
if (a[i][j] == 1){
     n++;
   }
 }
 }
 if (n == 0)
   printf("0\n");
 else if (n < 4)
printf("1\n");
  else
     printf("2\n");
 }
}
 }

    return 0;
}


#include<stdio.h>
#include<stdlib.h>

typedef struct{
    int a;
    int b;
    int c;
    int d;
    int e;
}list;

int main()
{
 int n;
 scanf("%d",&n);

 list* s=NULL;
 s=(list*)malloc(sizeof(list)*n);

 int i=0;
 for(;;){
     if(i>=n){
        break;
     }
     scanf("%d",&s[i].a);
     scanf("%d",&s[i].b);
     scanf("%d",&s[i].c);
     scanf("%d",&s[i].d);
     ++i;
 }

 int num;
 i=0;
 for(;;){
     if(i>=n){
        break;
     }
     num=0;
     if(s[i].a==1){
        ++num;
     }
     if(s[i].b==1){
        ++num;
     }
     if(s[i].c==1){
        ++num;
     }
     if(s[i].d==1){
        ++num;
     }
     s[i].e=num/2;
     ++i;
 }

 i=0;
 for(;;){
     if(i>=n){
        break;
     }
     printf("%d",s[i].e);
     if(i!=n-1){
        printf("\n");
     }
     ++i;
 }

 free(s);
}


// Online C compiler to run C program online
#include <stdio.h>

int main() {
    // Write C code here
    int t;
    scanf("%d",&t);
    while (t--){
        int arr[4];
        int count=0;
        int oneCount=0;
        scanf("%d %d",&arr[0],&arr[1]);
        scanf("%d %d",&arr[2],&arr[3]);
        for(int i=0;i<4;i++){
            if (arr[i]==1){
                oneCount+=1;
            }
        }
        if (oneCount==4){
            printf("%d",2);
        }
        else if (oneCount==0) printf("%d",0);
        else{
            printf("%d",1);
        }

    }
    return 0;
}


// Online C compiler to run C program online
#include <stdio.h>

int main() {
    // Write C code here
    int t;
    scanf("%d",&t);
    while (t--){
        int arr[4];
        int count=0;
        int oneCount=0;
        scanf("%d %d",&arr[0],&arr[1]);
        scanf("%d %d",&arr[2],&arr[3]);
        for(int i=0;i<4;i++){
            if (arr[i]==1){
                oneCount+=1;
            }
        }
        if (oneCount==4){
            printf("%d",2\n);
        }
        else if (oneCount==0) printf("%d\n",0);
        else{
            printf("%d\n",1);
        }

    }
    return 0;
}


#include <stdio.h>

int main()
{
    int t;
    int grass[2][2];
    int zeroes=0;
    scanf("%d",&t);
    for(int i=0;i<t;i++){
        zeroes = 0;
        scanf("%d %d",&grass[0][0],&grass[0][1]);
        scanf("%d %d",&grass[1][0],&grass[1][1]);
        if(grass[0][0]==0){
            zeroes++;
        }
        if(grass[1][0]==0){
            zeroes++;
        }
        if(grass[0][1]==0){
            zeroes++;
        }
        if(grass[1][1]==0){
            zeroes++;
        }
        if(zeroes == 0){printf("2");}
        if(zeroes == 1){printf("1");}
        if(zeroes == 3){printf("1");}
        if(zeroes == 4){printf("0");}
        if(zeroes == 2){printf("1");}}
        printf("\n");
    }

}


#include <stdio.h>

int main()
{
    int t;
    int grass[2][2];
    int zeroes=0;
    scanf("%d",&t);
    for(int i=0;i<t;i++){
        zeroes = 0;
        scanf("%d %d",&grass[0][0],&grass[0][1]);
        scanf("%d %d",&grass[1][0],&grass[1][1]);
        if(grass[0][0]==0){
            zeroes++;
        }
        if(grass[1][0]==0){
            zeroes++;
        }
        if(grass[0][1]==0){
            zeroes++;
        }
        if(grass[1][1]==0){
            zeroes++;
        }
        if(zeroes == 0){printf("2");}
        if(zeroes == 1){printf("1");}
        if(zeroes == 3){printf("1");}
        if(zeroes == 4){printf("0");}
        if(zeroes == 2){printf("1");}}
        printf("\n");
    }


#include<stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        int n;
        cnt=0;
        for(i=0;i<4;i++){
            scanf("%d",&n);
            if(n==1)
            cnt++;
        }
        if(cnt==0)
        printf("%d",0);
        else if(cnt!=4)
        printf("%d",1);
        else
        printf("%d",2);
        }
        return 0;
    }


#include<stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        int n,cnt,i;
        cnt=0;
        for(i=0;i<4;i++){
            scanf("%d",&n);
            if(n==1)
            cnt++;
        }
        if(cnt==0)
        printf("%d",0);
        else if(cnt!=4)
        printf("%d",1);
        else
        printf("%d",2);
        }
        return 0;
    }


#include <stdio.h>
int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        int i,j,sum=0,min;
        int a[2][2];
        for(i=0;i<2;i++){
            for(j=0;j<2;j++){
                scanf("%d",&a[i][j]);
                sum += a[i][j];
            }
        }
        if(sum==0){
            min = 0;
        }
        else if(sum==4){
            min = 2;
        }
        else{
            min = 1;
        }
        printf("%d",min);
    }
}


// a

#include<stdio.h>
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
{
	int field[2][2] = {{ 0 , 0 } , { 0 , 0 }};
	int line = 0;
	for(int i = 0 ; i < 2 ; ++i)
	{
		scanf("%d %d",&field[i][0],&field[i][1]);
		line += field[i][0]+field[i][1];
		printf("%d %d", field[i][0],field[i][1]);
	}
	if(line == 0 )
		printf("%d", 0 );
	else if(line == 4 )
		printf("%d", 2 );
	else
		printf("%d", 1);
}
	return 0;
}


#include <stdio.h>
int main(){
	int w;
	scanf("%d",&w);
	while(w--){
		int q[2][2];
		int i,j,k=0,temp=0;
		for(i=0;i<2;i++){
			for(j=0;j<2;j++){
				scanf("%d",&q[i][j]);
				k+=q[i][j];
			}
		}
		if(k==0)
		temp=0;
		else if(k==1||k==2)
		temp=1;
		else temp=2;
		printf("%d\n",temp);
	}

}


#include<stdio.h>

int main(){
    int t;
    scanf("%d",&t);
    for(int z=0;z<t;z++){
        int a;
        int x=0;
        for(int i=0;i<4;i++){
            scanf("%d",&a);
            if(a==1){
                x++;
            }
        }
        if(x==0)
            printf("0\n");
        else if(x==1)
            printf("1\n");
        else if(x==3){
            printf("2\n");
        }
        else if(x==2){
            printf("1\n");
        }
        else if(x==4){
            printf("2\n");
        }

    }

    return 0;
}


#include <stdio.h>

int main()
{

    int t;

    int c = 0;
    scanf("%d", &t);
    while (t)
    {
        c = 0;
        int tt;
        for (int i = 0; i < 4; i++)
            scanf("%d", &tt);
        if (tt)
        {
            c += 1;
        };
        if (c == 4)
        {
            printf("%d", 2);
        }
        else if (c == 0)
        {
            printf("%d", 0);
        }
        else
        {
            printf("%d", 1);
        }
        t--;
    }

    return 0;
}


#include<stdio.h>
int main()
{
    int t, a[4], i, j, sum=0;
    scanf("%d", &t);
    while(t--)
    {
        for(i=0; i<4; i++)
        {
            scanf("%d", &a[i]);
                sum+=a[i];
        }
        if(sum<1)
            printf("0\n");
        else if(sum>0 && sum<3)
            printf("1\n");
        else
            printf("2\n");
        sum=0;
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
  int t;
  scanf("%d", &t);
  int count = 0;
  while (t > 0)
  {
    int A[3];
    int B[3];
    for (int i = 0; i < 2; i++)
    {
      int x;
      scanf("%d", &x);
      A[i] = x;
      if (A[i] == 1)
      {
        count = count + 1;
      }
    }
    for (int j = 0; j < 2; j++)
    {
      int x;
      scanf("%d", &x);
      B[j] = x;
      if (B[j] == 1)
      {
        count = count + 1;
      }
    }
    if (count == 0)
    {
      printf("0\n");
    }
    else if (count == 1)
    {
      printf("1\n");
    }
    else if (count == 2)
    {
      printf("1\n");
    }
    else if (count == 3)
    {
      printf("1\n");
    }
    else
    {
      printf("2\n");
    }
    t = t - 1;
  }
}


/*  */

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>

typedef int TYPE;
typedef unsigned char UCHAR;

/* Translator is a function that enters numbers from the stack into the array */
void GetNumbersInArrayFromStr( TYPE *res, char *S, int N )
{
  char *Buf;
  int i = 0, l = 0, j, ofs = 0;

  for (i = 0; i < N; i++)
  {
    Buf = malloc(sizeof(char) * 100);

    l = 0;
    j = ofs;
    while (S[j] != ' ' && S[j] != 0)
    {
      Buf[j - ofs] = S[j];
      l++;
      j++;
    }
    Buf[l] = 0;
    res[i] = atoi(Buf);
    ofs += (l + 1);

    free(Buf);
  }
} /* End of 'GetNumbersInArrayFromStr' function */

/* Get string function */
void GetStr( char *str, int len )
{
  int i = 0;
  char ch;

  while ((ch = getchar()) != '\n' )
    if (str != NULL && i < len - 1)
      str[i++] = ch;
  if (str != NULL && i < len - 1)
    str[i] = 0;
} /* End of 'GetStr' function */

int main( void )
{
  int T, i, A[2][2], res = 0, x, y, ed = 0;

  scanf("%i", &T);
  for (i = 0; i < T; i++)
  {
    scanf("%i %i", &A[0][0], &A[0][1]);
    scanf("%i %i", &A[1][0], &A[1][1]);

    ed = 0;
    for (y = 0; y < 2; y++)
      for (x = 0; x < 2; x++)
        if (A[y][x])
          ed++;

    if (ed == 1)
      res = 1;
    else if (ed == 3)
      res = 1;
    else if (ed == 2)
    {
      if (A[0][0] == A[1][1])
        res = 1;
      else
        res = 1;
    }
    else if (ed == 4)
      res = 2;

    printf("%i\n", res);

  }

  /** /
  getchar();
  getchar();
  /**/
  return 0;
}


#include<stdio.h>
int t,a,b,c,d;
int main(){
	scanf("%d",&t);
	while(t--){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if((a&d)||(b&c))printf("2\n");
		else if(a|b|c|d)printf("1\n");
		else printf("0\n");
	}
}


#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void swap(int* a, int* b)
{
 int temp = *a;*a = *b; *b = temp;
}

void heapify(int arr[], int N, int i){
    int largest = i;

    int left = 2 * i + 1;
    int right = 2 * i + 2;
    if (left < N && arr[left] > arr[largest])
        largest = left;
    if (right < N && arr[right] > arr[largest])

        largest = right;
    if (largest != i) {

        swap(&arr[i], &arr[largest]);
        heapify(arr, N, largest);
    }
}
void heapSort(int arr[], int N)
{
    for (int i = N / 2 - 1; i >= 0; i--)

        heapify(arr, N, i);
    for (int i = N - 1; i >= 0; i--) {
        swap(&arr[0], &arr[i]);
        heapify(arr, i, 0);
    }
}

void fill(int a[],int n){
for(int i=0;i<n;i++){
scanf("%d",a+i);
}
}
void prt(int a[],int n){
for(int i=0;i<n;i++){
printf("%d ",a[i]);
}
}
int min(int a[],int n){int m=1000000001;
for(int i=0;i<n;i++){
	if(a[i]<m){m=a[i];
	}
}return m;
}
int max(int a[],int n){int m=0;
for(int i=0;i<n;i++){
	if(a[i]>m){m=a[i];
	}
}return m;
}
int main(){
int t,n,a,b,c,d;
scanf("%d",&t);
while(t--){
scanf("%d%d%d%d",&a,&b,&c,&d);int count=(a==1)+(b==1)+(c==1)+(d==1);
if(count>1&&count<4){puts("1");
}
else if(count==4){puts("2");
}
else{puts("0");
}
}
}


#include <stdio.h>
#include<math.h>
int main(void) {
	// your code goes here

     int t;
   scanf("%d",&t);
   for(int k=0;k<t;k++){
      int a[2][2];
       for(int i=0;i<2;i++){
          for(int j=0;j<2;j++){
              scanf("%d",&a[i][j]);
          }
      }

      int c=0;
      for(int i=0;i<2;i++){
          for(int j=0;j<2;j++){
              if(a[i][j]==1){
                  c=c+1;
              }
          }
      }
      printf("%d\n",c/2);
   }

	return 0;
}


#include <stdio.h>

int main(void){
    int t; scanf("%d",&t);
    for(int i = 0; i < t; i++){
        //Get the input
        int field[4]; int count = 0;
        for(int j = 0 ; j < 4; j++){
            scanf("%d",field[j]);
            //count the no. of 1's
            if(field[j] == 1){
                count++;
            }
        }
        if(count == 0){
            printf("0\n");
        }
        else if(count < 4){
            printf("1\n");
        }
        else{
            printf("2\n");
        }
    }
    return 0;
}


#include <stdio.h>
int main()
{
    int t,i,j,k;
    scanf("%d",&t);
    for(k=0;k<t;k++){
        int tab[2][2];
    for(i=0;i<2;i++){
        for(j=0;j<2;j++){
            scanf("%d",&tab[i][j]);
        }
    }
    int count=0;
    for(j=0;j<2;j++){
        if(tab[0][j]==1){
            count=count+1;
            break;
        }
    }
    for(j=0;j<2;j++){
        if(tab[1][j]==1){
            count=count+1;
            break;
        }
    }
    printf("%d\n",count);
    }
    return 0;

}


#include <stdio.h>
int solution(){
    int mat[2][2];
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            scanf("%d",&mat[i][j]);
        }
    }
    int count = 0;
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            if (mat[i][j]==1)
            {
                count++;
            }
        }
    }
    if (count==0)
    {
        printf("0\n");
    }
    else if (count==2 || count==3)
    {
        printf("1\n");
    }
    else
        printf("2\n");
    return 0;
}
int main(){
    int t;
    scanf("%d",&t);
    while (t--)
    {
        solution();
    }
    return 0;
}


#include<stdio.h>
int main( )
{
    int t, i, j, k, ara[2][2];
    scanf("%d", &t);
    for(i = 1; i <= t; i++)
    {
        int count = 0;
        for(j = 0; j < 2; j++)
        {
            for(k = 0; k < 2; k++)
            {
                scanf("%d", &ara[i][j]);
            }
        }
        for(j = 0; j < 2; j++)
        {
            for(k = 0; k < 2; k++)
            {
                if(ara[i][j] == 1)
                    count++;
            }
        }
        if(count == 0)
            printf("0\n");
        else if(count == 4)
            printf("2\n");
        else
            printf("1\n");
    }
    return 0;
}


#include<stdio.h>
#define MAX 16
int main()
{
	int t, a[MAX][MAX], i,j, sum=0;
	scanf("%d", &t);
	while(t--)
	{
		for(i=0; i<2; i++)
		{
			for(j=0; j<2; j++)
			{
				scanf("%d", &a[i][j]);
				if(a[i][j] == 1)
				{
					sum += a[i][j];
				}
			}
		}
		if(sum == 0)
			printf("0\n");
		else if(sum>0 && sum <3)
			printf("1\n");
		else if(sum>2)
			printf("2\n");
	}
	return 0;
}


#include<stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int a,b,c,d;
        scanf("%d %d",&a,&b);
        scanf("%d %d",&c,&d);
        int e=((a+b)+(c+d))/2;
        printf("%d\n",e);
    }
    return 0;
}


#include <stdio.h>

int main() {
    int a,b,c,d,t,count;
    scanf("%d",&t);
    while(t--)
    {
        count = 0;
        scanf("%d %d %d %d",&a,&b,&c,&d);
        if(a==1||d==1)
            count++;
        if(b==1||c==1)
            count++;

                printf("%d\n",count);
    }
    return 0;
}


#include <stdio.h>
int main()
{
	int t, i;
	scanf("%d", &t);
	while (t--)
	{
		int n, count = 0;
		for (i = 0; i < 4; i++)
		{
			scanf("%d", &n);
			if (n == 1)
				count++;

	}

	if (count == 0)
		printf("0");
	else if (count != 4)
		printf("1");
	else
		printf("2");
}
}


#include<stdio.h>
int main() {
    int t;
    scanf("%d", &t);
    for(int i = 0;i < t;i++) {
        int a[2][2];
        int count = 0;
        for(int j = 0;j<2;j++) {
            for(int k = 0;k < 2;k++) {
                scanf("%d", &a[j][k]);
                if (a[j][k]) {
                    count++;
                }
            }
        }
        printf("%d\n", count/2);

    }
}


#include<stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,c=0;
        for(int i=0;i<4;i++)
        {
            scanf("%d",&n);
            if(n==1)
            c++;
        }
        printf("%d\n",c/2);
    }
    }


#include<stdio.h>
int main (){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int arr[4];
        int count=0;
        for(int j=0;j<=3;j++){
            scanf("%d",&arr[j]);
            if(arr[j]==1){
                count+=1;
            }
        }
        if(count==0){
            printf("%d\n",0);
        }
        else if (count==1||count==2){
            printf("%d\n",1);
        }

        else{
            printf("%d\n",2);
        }

    }
}


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int t,c=0;
    scanf("%d",&t);
    while(t--)
    {
        c=0;
        for(int i=0;i<4;++i)
        {
            int a;
            scanf("%d",&a);
            if(a==1)
                c++;
        }
        if(c==0)
            printf("%d",c);
        else if((c%2)!=0)
            printf("1");
        else
            printf("%d",c/2);
    }
}


#include <stdio.h>

int main ()
{
    int i,n,a,b,c,d,ans;
    scanf("%d", &n);

    for (i=0;i<n;i++)
    {
        scanf("%d %d\n", &a,&b);
        scanf("%d %d", &c,&d);

        if (a==0 && b==0 && c==0 && d==0)
        {
            ans=0;
        }

        else if  (a==d || b==c)
        {
            ans=2;
        }
        else
        {
            ans=1;
        }

        printf("%d\n", ans);
    }

    return 0;
}


#include <stdio.h>
int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        int m = 2, n = 2, sum;
        int a[m][n], r, c;
        for(r = 0; r < m; r++)
        {
            for(c = 0; c < n; c++)
            {
                scanf("%d", &a[r][c]);
            }
        }
        sum = a[0][0] + a[0][1];
        printf("%d\n", sum);
    }
    return 0;
}


#include <stdio.h>

int main(){
    int T;
    scanf("%d",&T);
    while (T--)
    {
        int n,ans = 0;
        for (size_t i = 0; i < 4; i++)
        {
            scanf("%d",&n);
            ans+=n;
        }
        if (ans==0)
        {
            printf("0\n");
        }
        else if (ans ==1 || ans == 2)
        {
            printf("1\n");
        }
        else
        {
            printf("2\n");
        }

    }

}


#include <stdio.h>

int main()
{
	int t,a[4],sum = 0;
	scanf("%i", &t);
	for (int j = 0; j < t; j++)
	{
		for (int i = 0; i < 4; i++)
		{
			scanf("%i", &a[i]);
			sum += a[i];
		}
		int moves;
		if (sum == 0)
		{
			moves = 0;
			printf("%i\n", moves);
		}
		else if(sum == 4)
		{
			moves = 2;
			printf("%i\n", moves);
		}
		else
		{
			moves = 1;
			printf("%i\n", moves);
		}
	}
}


#include <stdio.h>
void solve() {
    int a,b,c,d,count=0;
    scanf("%d %d",&a,&b);
    scanf("%d %d",&c,&d);
    if (a==1)
        count++;
    if (b==1)
        count++;
    if (c==1)
        count++;
    if (d==1)
        count++;
    if (count==0) {
        printf("0");
    }
    else if (count==1) {
        printf("1");
    }
    else if (count==2) {
        printf("1");
    }
    else if (count==3) {
        printf("1");
    }
    else {
        printf("2");
    }
}
int main() {
    int t;
    scanf("%d",&t);
    while (t--)
        solve();
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
int main(){
    int t;
    scanf("%d", &t);
    while(t--){
        int n, m, k;
        scanf("%d%d%d", &n, &m, &k);
        if(m<2){
            if(k==0)printf("YES\n");
            else printf("NO\n");
        }
        else if(n<2){
            if(k==m/2)printf("YES\n");
            else printf("NO\n");
        }
        else if(n%2==1){
            if((k-(m/2))>=0 && (k-(m/2))%2==0){
                printf("YES\n");
            }
            else{
                printf("NO\n");
            }
        }
        else{
            if(m%2==1){
                if(k*2>(m-1)*n){
                    printf("NO\n");
                }
                else{
                    if(k%2==0){
                        printf("YES\n");
                    }
                    else{
                        printf("NO\n");
                    }
                }
            }

        }
    }
    //system("pause");
    return 0;
}


#include<stdio.h>

int n, m, k, i, j, sum, t, tc, det;
int main(void)
{
    scanf("%d", &t);
    for(tc=1;tc<=t;tc++)
    {
        det=2;
        scanf("%d %d %d", &n, &m, &k);
        if(n==1 || m==1)
        {
            if(m==1)
            {
                printf("%s\n", k==0 ? "YES" : "NO");
                continue;
            }
            if(n==1)
            {
                printf("%s\n", k==(m*n)/2 ? "YES" : "NO");
                continue;
            }
        }
        if(n%2==1 && (m%4==1 || m%4==2)) det=1;
        if(k%2==det%2) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


#include <stdio.h>

void testcase();

int main() {
    int t;
    scanf("%d", &t);
    for (int i = 0; i < t; i++) {
        testcase();
    }
    return 0;
}

void testcase() {
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    if (m == 1 && k >= 1) {
        printf("NO\n");
        return;
    }
    if ((n - k) % 2 != 0) {
        printf("NO\n");
        return;
    }
    printf("YES\n");
    return;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
long long int min(long long int a, long long int b)
{
    return a < b ? a : b;
}
int cmpfunc (const void * a, const void * b) {
    return ( *(int*)a - * (int*)b );
}
typedef long long ll;
void test();
int main()
{
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/
    int t;
    scanf("%d", &t);
    while (t--)
    {
        test();
    }
    return 0;
}
void test()
{
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    if (n % 2 == 0 && m % 2 == 0)
    {
        if (k % 2 == 0)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    else if (n % 2 == 0 && m % 2 != 0)
    {
        if (k > (n * (m / 2)))
        {
            printf("NO\n");
        }
        else if (k % 2 == 0)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    else if (n % 2 != 0 && m % 2 == 0)
    {
        if (k == n * (m / 2))
        {
            printf("YES\n");
        }
        else if (k % 2 != 0)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
}


#include<stdio.h>
int main()
{
	int n,m,t,k;
	scanf("%d",&t);
	while(t--){
		scanf("%d %d %d",&n,&m,&k);
		int sum=n*m/2;
		if(n%2==1){
			sum-=m/2;
			k-=m/2;
		}
		if(m%2==1){
			sum-=n/2;
		}
		if(k<0||k%2==1||k>sum){
			printf("NO\n");
		}else printf("YES\n");*
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
/*#define debug(x);
printf(x);*/

void init()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r"  ,stdin);
	freopen("output.txt" , "w" ,stdout);
	#endif
}
//** pritishcf307 **//
//**-------------------------------------------------------------**//

int main()
{
	init();
	long long int t;
	scanf("%lld",&t);
	while(t--)
	{
		long long int n,m,k;
		scanf("%lld %lld %lld",&n,&m,&k);
		if(n%2==1 & m%2==0)
		{
			if(k%2==0)
			{
				printf("YES");
			}
			else
			{
				printf("NO");
			}
		}
		if(n%2==0 && n%2==1)
		{
			if(k<m/2)
			{
				printf("NO");
			}
			else
			{
				k=k-m/2;
				if(k%2==0)
				{
					printf("YES");
				}
				else
				{
					printf("NO");
				}
			}
		}
		/*debug(k);
		debug(m);
		debug(n);*/
		if(n%2==0 && m%2==1)
		{
			if(k<=((m*n)/2-(n/2)) && k%2==0)
			{
				printf("YES");
			}
			else
			{
				printf("NO");
			}
		}
		printf("\n");
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int row,column,k;
void solve()
{
    if(column&1){
        if((k<=(column/2*row)) && (k%2==0))
            printf("YES\n");
        else
            printf("NO\n");
    }
    else{
        if(row%2 == k%2)
            printf("YES\n");
        else
            printf("NO\n");
    }
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%d%d%d",&row,&column,&k);
        solve();
    }
    return 0;
}


#include <stdio.h>
int main(){
    int a,b;
    scanf("%d",&a);
    b = a + 1;
    printf("%d\n",&b);
    return 0;
}


#include<stdio.h>
int main(){
    int r;
    scanf("%d",&r);
    printf("%d\n",r);
    return 0;
}


#include <stdio.h>
int main() {
	printf("1");
}


#include<stdio.h>
int main()
{
       int n,ans=0,j;
       scanf("%d",&n);
       for(n;j>9;)
       {
              j=n%9;

       }
       printf("%d",j);
       return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    cin>>n;
    if (n % 9 == 0)
        printf("9\n");
    else
        printf("%d\n",(n % 9));
    return 0;
}


#include<stdio.h>
int main(){
    int a;
    scanf("%d",&a);
    printf("%d\n",(a%9));
    return 0;
}


#include<stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    printf("%d", n ? (n - 1) % 9 : 0);
    return 0;
}


#include<stdio.h>
int main()
{
	int a;
	scanf("%d",&a);
	printf("%d",&a);
}


#include<stdio.h>
int main(){
int a;
cin>>a;
printf("%d",2-(a*a));
return 0;
}


#include<stdio.h>
char mp[9][9];
int dir;
int n,m,x,y;
int get_dis(int dir){
  if(dir==0&&y==m)return 100;
  if(dir==1&&x==n)return 100;
  if(dir==0){
    for(int i=y+1;i<=m;i++)
      if(mp[x][i]=='*')return i-y;
  }else
    for(int i=x+1;i<=n;i++)
      if(mp[i][y]=='*')return i-x;
  return 100;
}

int main(void){
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++)scanf("%s",mp[i]+1);
  dir=0;
  int ans=0;
  x=1;y=1;
  for(int i=0;i<n+m;i++){
    if(mp[x][y]=='*')ans++;
    //    printf("%d %d\n",x,y);
    if(get_dis(dir)<get_dis(!dir)){
      if(dir==0)y++;
      else x++;
    }else if(get_dis(dir)>get_dis(!dir)){
      if(dir==0)
	x++;
      else
	y++;
      dir=!dir;
    }else{
      x++;
    }
  }
  printf("%d\n",ans);
  return 0;
}


#include <stdio.h>
#include <stdlib.h>

int	getmin(int a, int b)
{
	if (a < b)
		return (a);
	return (b);
}
int	getmax(int a, int b)
{
	if (a > b)
		return (a);
	return (b);
}

int	*get_tab(int *c, int size)
{
	int	*t;
	int	i;
	int	j;

	i = 0;
	j = 0;
	t = (int *)malloc (sizeof(int) * size);
	while (i < size)
	{
		if ((c[j] + c[j + 1]) % 2 == 0)
			t[i] = getmax(c[j], c[j + 1]);
		else
			t[i] = getmin(c[j], c[j + 1]);

		j += 2;
		i++;
	}
	return (t);
}

int	pow_t(int a, int b)
{
	int	i;

	i = 1;
	while (i < b)
	{
		a = a * 2;
		i++;
	}
	return (a);
}

int main()
{
	int	t;
	int	cas;
	int	i;
	int	j;
	int	size;
	int	k;
	int	*tab;
	int	*tmp;
	int	arr;

	scanf("%d",&t);
	int	n[t];
	i = 0;
	while (i < t)
	{
		scanf("%d",&n[i]);
		i++;
	}
	cas = 0;
	while (cas < t)
	{
		if (n[cas] == 1)
			printf("1\n");
		else
		{
			arr = pow_t(2, n[cas]);
			tab = (int *)malloc(sizeof(int) * arr / 2);
			i = 1;
			j = 0;
			while (i < arr)
			{
				if ((i + i + 1) % 2 == 0)
					tab[j] = getmax(i, i + 1);
				else
					tab[j] = getmin(i, i + 1);
				i = i + 2;
				j++;
			}
			size = arr / 2;
			k = 1;
			while ((k < n[cas]))
			{
				size /= 2;
				tmp = tab;
				tab = get_tab(tab, size);
				free(tmp);
				k++;
			}
			free(tab);
			if ((tab[0] + tab[1]) % 2 == 0)
				printf("%d\n",getmax(tab[0], tab[1]));
			else
				printf("%d\n",getmin(tab[0], tab[1]));
		}
		cas ++;
	}
	return (0);
}


#include <stdio.h>
#include <stdlib.h>
int winner(int stages);

int main()
{
    int num;
    int *stages;
    scanf("%d", &num);
    stages = (int *)malloc(num * sizeof(int));
    for (int i = 0; i < num; i++) {
        scanf("%d", stages + i);
    }
    for (int i = 0; i < num; i++) {
        printf("%d\n", winner(stages[i]));
    }
    return 0;
}

int winner(int stages)
{
    int player_num = 1 << stages;
    int *players = (int *)malloc(player_num * sizeof(int));
    for (int i = 0; i < player_num; i++) {
        players[i] = i + 1;
    }
    for (int i = player_num / 2; i != 0; i = i / 2) {
        for (int j = 0; j < i; j++) {
            players[j] = ((players[2 * j + 1] + players[2 * j]) % 2)? players[2 * j] : players[2 * j + 1];
        }
    }
    free(players);
    return players[0];
}


#include<stdio.h>
#include<math.h>
int powerOf2(int n){
    int i,j=1;
    for(i=0;i<n;i++){
        j = j*2;
    }
    return j;
}
int main(){

    int t,z;
    scanf("%d", &t);
    for(z=0;z<t;z++){
        int n;
        scanf("%d",&n);

        printf("%d\n",powerOf2(n));
    }

    return 0;
}


#include<stdio.h>

 int main()
 {
    int tt;
    scanf("%d",&tt);
    while(tt--)
    {
      int n;
      scanf("%d",&n);
      printf("%d\n",(1>>n)-1);
    }
 }


#include <stdio.h>

long long int gop(int n){
    long long ans = 1;
    for(int i = 0;i < n;i++){
        ans = ans*2;
    }

    return ans;
}

int main(){

    int t;
    scanf("%d",&t);
    while(t--){
      int n;
      scanf("%d",&n);

      printf("%lld",gop(n));
    }

    return 0;
}


#include"stdio.h"

int main()
{
    int n;
    scanf("%d",&n);
    int result = 2;
    for(int i = 1; i < n; ++i)
    {
        result *= 2;
    }
    printf("%d",result-1);
    return 0;
}


#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++)
	{	int t,j=0;
		long long nx=1;
		scanf("%d",&t);
		getchar();
		for(j=0;j<t;j++) nx=nx*2;
		printf("%lld",nx-1);
	}
}


#include <stdio.h>
#include <stdlib.h>
#include  <math.h>
int main()
{
    int n;
    scanf("%d",&n);
    long int k =1;
    for(int i =0; i<n;i++)
    {
        k = 2*k;
    }
    printf("%ld", k-1);
}


#include <stdio.h>

int main()
{
    int i,t,n;
    scanf("%d",&t);
    for (i=0;i<t;i++)
    {
        scanf("%d",&n);
        printf("%d\n",n-1);
    }
}


#include <stdio.h>

int main()
{
    int i,t,n;
    long long ans;
    scanf("%d",&t);
    for (i=0;i<t;i++)
    {
        scanf("%d",&n);
        ans=1;
        for (j=0;j<n;j++) ans*=2;
        printf("%lld\n",ans-1);
    }
}


#include<stdio.h>

int main()
{
    int test,n;
    scanf("%d",&test);

    for(int i=0 ;i<n;i++)
    {
        scanf("%d",&n);
        int result =0;
        for(int j=0;j<n-2;j++)
        {
             result = (2 * 2);
        }

        if(result > 1)
        printf("%d\n",result-1);
        else
            printf("%d\n",n);
    }

    return 0;
}


#include<stdio.h>
void win(int n)
{
	if(n==1)
	printf("1\n");
	if(n==2)
	printf("3\n");
	if(n>2)
	{
		printf("%d\n",3+(n-2)*4);
	}
}
int main ()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		win(n);
	}
 }


#include<stdio.h>

int main()
{
    int t,n,ans;
    scanf("%d",&t);

    while(t--)
    {
        ans=1;
        scanf("%d",&n);

        for(int i=0;i<n;i++)
        {
            ans=ans*2;
        }
        printf("%d",(ans-1));

    }
    return 0;
}


#include <stdio.h>

int tests;
scanf("%d", &tests);
for(int i=0; i<tests; i++){
    int n;
    scanf("%d", &n);
    if(n==1){
        printf("%d\n", 1);
    }else{
        int t = 1;
        for(int j=1; j<=n;j++){
            t = t*2;
        }
        printf("%d\n", t-1);
    }
}


#include<stdio.h>
int answer(int x,int y,int u)
{
	if (x == y)
	{
		return x;
	}
	else {
		if (u == 1)
		{
			return answer((x+y)/2+1, y, 0);
		}
		if (u == 0)
		{
			return answer(x, (x+y) / 2, 1);
		}
	}
}
int main(void)
{
	int t;
	scanf("%d", &t);
	for (int i = 0; i < t; i++)
	{
		int p;
		scanf("%d", &p);
		int m = 1;
		for (int o = 1; o <= p; o++)
		{
			m = 2 * m;
		}
		int v;
		if (p % 2 == 0)
		{
			v=answer(1, m, 1);
		}
		else {
			v=answer(1, m, 0);
		}
		printf("%d\n", v);
	}
	return 0;
}


#include <stdio.h>

int main() {
  int t, n;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    printf("%lld\n", 1ll << n - 1);
  }
  return 0;
}


#include <stdio.h>

int main()
{
	int n;
	scanf("%d",&n);
	while(n--)
	{
		int num;
		scnaf("%d",&num);
		num = 1 << num;
		num--;
		printf("%d\n",num);

	}

}


#include <stdio.h>
void solve();
int main() {

  int i, t;
  scanf("%d",&t);
  for(i=0;i<t;i++){
    solve();
  }

return 0;
}

void solve(){
    int i,n,m=2,p=2;
    scanf("%d",&n);
    for(i=1;i<n;i++){
        m=m*p;
    }
    printf("%d\n",m-1);
    }
}


#include <stdio.h>
#include <stdlib.h>

#define N	200000
#define L_	19	/* L_ = ceil(log2(N * 2 + 1)) */
#define N_	(1 << L_)
#define MD	998244353

int min(int a, int b) { return a < b ? a : b; }

long long power(long long a, int k) {
	long long p = 1;

	while (k) {
		if (k & 1)
			p = p * a % MD;
		a = a * a % MD;
		k >>= 1;
	}
	return p;
}

int vv[N + 1], ff[N + 1], gg[N + 1], mobius[N + 1];
int *wwu[L_ + 1], *wwv[L_ + 1], vv_[L_ + 1];

void init() {
	int i, j, l, u, v;

	ff[0] = gg[0] = 1;
	for (i = 1; i <= N; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;
		ff[i] = (long long) ff[i - 1] * i % MD;
		gg[i] = (long long) gg[i - 1] * vv[i] % MD;
	}
	for (i = 2; i <= N; i++) {
		if (mobius[i])
			continue;
		for (j = i; j <= N; j += i)
			mobius[j]++;
	}
	for (i = 2; i <= N / i; i++)
		for (j = i * i; j <= N; j += i * i)
			mobius[j] = -1;
	for (i = 1; i <= N; i++)
		mobius[i] = mobius[i] == -1 ? 0 : (mobius[i] % 2 == 0 ? 1 : -1);
	u = power(3, MD - 1 >> L_), v = power(u, MD - 2);
	for (l = L_; l > 0; l--) {
		int n = 1 << l, m = n >> 1;

		wwu[l] = (int *) malloc(m * sizeof *wwu[l]);
		wwv[l] = (int *) malloc(m * sizeof *wwv[l]);
		wwu[l][0] = wwv[l][0] = 1;
		for (i = 1; i < m; i++) {
			wwu[l][i] = (long long) wwu[l][i - 1] * u % MD;
			wwv[l][i] = (long long) wwv[l][i - 1] * v % MD;
		}
		vv_[l] = power(1 << l, MD - 2);
		u = (long long) u * u % MD, v = (long long) v * v % MD;
	}
	vv_[0] = 1;
}

int choose(int n, int k) {
	return (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

void ntt_(int *aa, int l, int inverse) {
	if (l) {
		int n = 1 << l, m = n >> 1, *ww = inverse ? wwv[l] : wwu[l], i, j;

		ntt_(aa, l - 1, inverse), ntt_(aa + m, l - 1, inverse);
		for (i = 0; (j = i + m) < n; i++) {
			int a = aa[i], b = (long long) aa[j] * ww[i] % MD;

			if ((aa[i] = a + b) >= MD)
				aa[i] -= MD;
			if ((aa[j] = a - b) < 0)
				aa[j] += MD;
		}
	}
}

void ntt(int *aa, int l, int inverse) {
	int n = 1 << l, i, j;

	for (i = 1, j = 0; i < n; i++) {
		int b = n >> 1, tmp;

		while ((j ^= b) < b)
			b >>= 1;
		if (i < j)
			tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
	}
	ntt_(aa, l, inverse);
}

int solve(int n, int k) {
	static int aa[N_], bb[N_];
	int n_, l_, i, ans;

	k = min(k, n);
	l_ = 0;
	while (1 << l_ < k + k + 1)
		l_++;
	n_ = 1 << l_;
	for (i = 0; i < n_; i++)
		aa[i] = i <= k ? (long long) power(i, n) * gg[i] % MD : 0;
	for (i = 0; i < n_; i++)
		bb[i] = i <= k ? (long long) (i % 2 == 0 ? 1 : MD - 1) * gg[i] % MD : 0;
	ntt(aa, l_, 0), ntt(bb, l_, 0);
	for (i = 0; i < n_; i++)
		aa[i] = (long long) aa[i] * bb[i] % MD;
	ntt(aa, l_, 1);
	ans = MD - 1;
	for (i = 0; i <= k; i++)
		ans = (ans + (long long) aa[i] * vv_[l_]) % MD;
	return ans;
}

int main() {
	int n, k, d, ans;

	init();
	scanf("%d%d", &n, &k);
	if (k == 1) {
		printf("1\n");
		return 0;
	}
	ans = 0;
	for (d = 1; d < n; d++)
		if (mobius[d])
			ans = (ans + solve((n + d - 1) / d, k) * mobius[d]) % MD;
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

#define N	200000
#define L_	19	/* L_ = ceil(log2(N * 2 + 1)) */
#define N_	(1 << L_)
#define MD	998244353

int min(int a, int b) { return a < b ? a : b; }

long long power(long long a, int k) {
	long long p = 1;

	while (k) {
		if (k & 1)
			p = p * a % MD;
		a = a * a % MD;
		k >>= 1;
	}
	return p;
}

int vv[N + 1], ff[N + 1], gg[N + 1], mobius[N + 1];
int *wwu[L_ + 1], *wwv[L_ + 1], vv_[L_ + 1];

void init() {
	int i, j, l, u, v;

	ff[0] = gg[0] = 1;
	for (i = 1; i <= N; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;
		ff[i] = (long long) ff[i - 1] * i % MD;
		gg[i] = (long long) gg[i - 1] * vv[i] % MD;
	}
	for (i = 2; i <= N; i++) {
		if (mobius[i])
			continue;
		for (j = i; j <= N; j += i)
			mobius[j]++;
	}
	for (i = 2; i <= N / i; i++)
		for (j = i * i; j <= N; j += i * i)
			mobius[j] = -1;
	for (i = 1; i <= N; i++)
		mobius[i] = mobius[i] == -1 ? 0 : (mobius[i] % 2 == 0 ? 1 : -1);
	u = power(3, MD - 1 >> L_), v = power(u, MD - 2);
	for (l = L_; l > 0; l--) {
		int n = 1 << l, m = n >> 1;

		wwu[l] = (int *) malloc(m * sizeof *wwu[l]);
		wwv[l] = (int *) malloc(m * sizeof *wwv[l]);
		wwu[l][0] = wwv[l][0] = 1;
		for (i = 1; i < m; i++) {
			wwu[l][i] = (long long) wwu[l][i - 1] * u % MD;
			wwv[l][i] = (long long) wwv[l][i - 1] * v % MD;
		}
		vv_[l] = power(1 << l, MD - 2);
		u = (long long) u * u % MD, v = (long long) v * v % MD;
	}
	vv_[0] = 1;
}

int choose(int n, int k) {
	return (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

void ntt_(int *aa, int l, int inverse) {
	if (l) {
		int n = 1 << l, m = n >> 1, *ww = inverse ? wwv[l] : wwu[l], i, j;

		ntt_(aa, l - 1, inverse), ntt_(aa + m, l - 1, inverse);
		for (i = 0; (j = i + m) < n; i++) {
			int a = aa[i], b = (long long) aa[j] * ww[i] % MD;

			if ((aa[i] = a + b) >= MD)
				aa[i] -= MD;
			if ((aa[j] = a - b) < 0)
				aa[j] += MD;
		}
	}
}

void ntt(int *aa, int l, int inverse) {
	int n = 1 << l, i, j;

	for (i = 1, j = 0; i < n; i++) {
		int b = n >> 1, tmp;

		while ((j ^= b) < b)
			b >>= 1;
		if (i < j)
			tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
	}
	ntt_(aa, l, inverse);
}

int solve(int n, int k) {
	static int aa[N_], bb[N_];
	int n_, l_, i, ans;

	l_ = 0;
	while (1 << l_ < k + k + 1)
		l_++;
	n_ = 1 << l_;
	for (i = 0; i < n_; i++)
		aa[i] = i <= k ? (long long) power(i, n) * gg[i] % MD : 0;
	for (i = 0; i < n_; i++)
		bb[i] = i <= k ? (long long) (i % 2 == 0 ? 1 : MD - 1) * gg[i] % MD : 0;
	ntt(aa, l_, 0), ntt(bb, l_, 0);
	for (i = 0; i < n_; i++)
		aa[i] = (long long) aa[i] * bb[i] % MD;
	ntt(aa, l_, 1);
	ans = MD - 1;
	for (i = 0; i <= k; i++)
		ans = (ans + (long long) aa[i] * vv_[l_]) % MD;
	return ans;
}

int main() {
	int n, k, d, ans;

	init();
	scanf("%d%d", &n, &k);
	if (k == 1) {
		printf("1\n");
		return 0;
	}
	ans = 0;
	for (d = 1; d < n; d++)
		if (mobius[d])
			ans = (ans + solve((n + d - 1) / d, k) * mobius[d]) % MD;
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>

typedef long long ll;

int mod = 998244353;

ll qPow(ll a, ll  b) {
	ll ret = 1;
	while(b) {
		if(b&1)
			ret = ret * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return ret;
}

int main() {
    int n, x;
    scanf("%d %d", &n, &x);
	ll C[n+1][n+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++) {
			if(!j)
				C[i][j] = 1;
			else
				C[i][j] = (C[i-1][j] + C[i-1][j-1]) % mod;
		}
	}
	ll f[n+1][x+1];
	for(int i=2;i<=n;i++){
		for(int j=1;j<=x;j++) {
			if(j<i) {
				f[i][j] = qPow(j, i);
			} else {
				f[i][j] = qPow(i-1, i);
				for(int k=2;k<=i;k++) {
					f[i][j] = (f[i][j]+C[i][k]*qPow(i-1,i-k)%mod*f[k][j-i+1]%mod)%mod;
				}
			}
		}
	}

    printf("%lld", f[n][x]);
    return 0;
}


#include <stdio.h>
#include <string.h>

typedef long long ll;

int mod = 998244353;

ll qPow(ll a, ll  b) {
	ll ret = 1;
	while(b) {
		if(b&1)
			ret = ret * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return ret;
}

int main() {
    int n, x;
    scanf("%d %d", &n, &x);
	ll C[n+1][n+1];
	memset(C,0,sizeof(C));
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++) {
			if(!j)
				C[i][j] = 1;
			else
				C[i][j] = C[i-1][j] + C[i-1][j-1];
				if(C[i][j] >= mod)
				    C[i][j] -= mod

		}
	}
	ll f[n+1][x+1];
	memset(f,0,sizeof(f));
	for(int i=2;i<=n;i++){
		for(int j=1;j<=x;j++) {
			if(j<i) {
				f[i][j] = qPow(j, i);
			} else {
				f[i][j] = qPow(i-1, i);
				for(int k=2;k<=i;k++) {
					f[i][j] = (f[i][j]+C[i][k]*qPow(i-1,i-k)%mod*f[k][j-i+1]%mod)%mod;
				}
			}
		}
	}

    printf("%lld", f[n][x]);
    return 0;
}


#include <stdio.h>
#include <string.h>

typedef unsigned long long ll;
typedef unsigned int int;

int mod = 998244353;

ll qPow(ll a, ll  b) {
	ll ret = 1;
	while(b) {
		if(b&1)
			ret = ret * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return ret;
}

int main() {
    int n, x;
    scanf("%u %u", &n, &x);
	int C[n+1][n+1];
	memset(C,0,sizeof(C));
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++) {
			if(!j)
				C[i][j] = 1;
			else
				C[i][j] = C[i-1][j] + C[i-1][j-1];
				if(C[i][j] >= mod)
				    C[i][j] -= mod;

		}
	}
	ll f[n+1][x+1];
	memset(f,0,sizeof(f));
	for(int i=2;i<=n;i++){
		for(int j=1;j<=x;j++) {
			if(j<i) {
				f[i][j] = qPow(j, i);
			} else {
				f[i][j] = qPow(i-1, i);
				for(int k=2;k<=i;k++) {
					f[i][j] = (f[i][j]+C[i][k]*qPow(i-1,i-k)%mod*f[k][j-i+1]%mod)%mod;
				}
			}
		}
	}

    printf("%llu", f[n][x]);
    return 0;
}


#include <stdio.h>
#include <string.h>

typedef unsigned long long ll;
typedef unsigned int uint;

int mod = 998244353;

uint pp[501][501];

ll qPow(uint a, uint b)
{
  if (pp[a][b] > 0)
  {
    return pp[a][b];
  }
  ll ret = 1, aa = a;
  while (b)
  {
    if (b & 1)
      ret = ret * aa % mod;
    aa = aa * aa % mod;
    b >>= 1;
  }
  pp[a][b] = ret;
  return ret;
}

uint C[501][501];
uint inited = 0;
void init()
{
  if (inited)
    return;
  inited = 1;
  memset(pp, 0, sizeof(pp));
  memset(C, 0, sizeof(C));
  for (uint i = 0; i <= 500; i++)
  {
    for (uint j = 0; j <= i; j++)
    {
      if (!j)
        C[i][j] = 1;
      else
        C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
      if (C[i][j] >= mod)
        C[i][j] -= mod;
    }
  }
}
ll f[501][501];
int main()
{
  uint n, x;
  scanf("%u %u", &n, &x);
  init();
  memset(f, 0, sizeof(f));
  for (uint i = 2; i <= n; i++)
  {
    for (uint j = 1; j <= x; j++)
    {
      if (j < i)
      {
        f[i][j] = qPow(j, i);
      }
      else
      {
        f[i][j] = qPow(i - 1, i);
        for (uint k = 2; k <= i; k++)
        {
          f[i][j] = (f[i][j] + C[i][k] * qPow(i - 1, i - k) % mod * f[k][j - i + 1] % mod) % mod;
        }
      }
    }
  }

  printf("%llu", f[n][x]);
  return 0;
}


#include<stdio.h>
#include<math.h>
int func(int m, int n, int a[]) {
	int sum = 0;
	for (int i = 1; i <= m; i++) {
		int count = 0;
		for (int k = 1; k <= n; k++) {
			for (int j = 1; j < i; j++) {
				if (i * k % j == 0 && i * k <= n * j) {
					count++;
					break;
				}
			}
		}

		sum += n-count;
		a[i] = sum;
	}
	return sum;
}

int main() {
	int m, n;
	scanf("%d%d",&n,&m);
	int a[20];
	int num[20]={0};

	int k,maxi=19;
	num[1] = n;
	for (int i = 2; i < 20;i++) {
		k = int(pow(double(n), 1.0 / double(i)));
		if (pow(n, i) <= k)
			k++;
		if (k == 1) {
			maxi = i - 1;
			break;
		}
		num[i] = k-1;
		//printf("%d ", k);
	}
	for (int i = maxi; i >= 2;i--) {
		for (int j = 1; j < i; j++) {
			num[j] -= num[i] * (i / j);
		}
	}
	int sum = 0;
	func(maxi, m,a);
	for (int i = 0; i <= maxi; i++) {
		sum += a[i] * num[i];
	}
	sum -= (m - 1);
	printf("%d", sum);
	//for (int i = 1; i <= maxi; i++)
		//printf("%d ",num[i]);
	return 0;

}


#include<stdio.h>
#include<math.h>
int func(int m, int n, int a[]) {
	int sum = 0;
	for (int i = 1; i <= m; i++) {
		int count = 0;
		for (int k = 1; k <= n; k++) {
			for (int j = 1; j < i; j++) {
				if ((i * k) % j == 0 && i * k <= n * j) {
					count++;
					break;
				}
			}
		}

		sum += n-count;
		a[i] = sum;
	}
	return sum;
}

int main() {
	int m, n;
	scanf("%d%d",&n,&m);
	if (n == 1) {
		printf("1");
		return 0;
	}
	if (m == 1) {
		printf("%d", n);
		return 0;
	}

	int a[20]={0};
	int num[20]={0};

	int k,maxi=19;
	num[1] = n - 1;

	for (int i = 2; i*i <= n; i++) {
		int p = 1;
		for (int k = 1; k < 21; k++) {
			p *= i;
			if (p > n) {
				num[k-1]++;

				break;
			}
		}

	}

	for (int i = maxi; i >= 2; i--) {
		if (num[maxi] == 0) {
			break;
		}
		for (int j = 2; j < i; j++) {
			{
			num[i/j] -= num[i];
			}
		}
	}
	num[1] = n - 1;
	for (int i = maxi; i >= 2; i--) {
		num[1] -= num[i] * i;
	}
	long long int sum = 0;
	func(maxi, m,a);
	for (int i = 1; i <= maxi; i++) {

		sum += (long long int)a[i] * num[i];
	}
	sum += 1;
	printf("%lld", sum);

	return 0;

}


#include <stdio.h>
#include <string.h>

#define N	1000000

int min(int a, int b) { return a < b ? a : b; }

int kk[N + 1];

void init() {
	int a, b, k;

	memset(kk, 0x3f, (N + 1) * sizeof *kk);
	for (a = 2; a <= N; a++) {
		b = a, k = 1;
		while (1) {
			if (b > N / a)
				break;
			b *= a, k++;
			kk[b] = min(kk[b], k);
		}
	}
}

int main() {
	int n, m, i;
	long long ans;

	init();
	scanf("%d%d", &n, &m);
	ans = 1;
	for (i = 2; i <= n; i++)
		ans += m - m / kk[i];
	printf("%lld\n", ans);
	return 0;
}


#include<stdio.h>
int main(){
 int t;
 scanf("%d",&t);

 while(t--){
  int n,k;
  int max=1e9+7;
  scanf("%d%d",&n,&k);
  long long int ans=1;
  for(int i=1;i<=n;i++){
   ans=(ans*i)%max;
  }
  printf("%lld",ans)
 }
 return 0;
}


#include<stdio.h>
int main(){
 int t;
 scanf("%d",&t);

 while(t--){
  int n,k;
  int max=1e9+7;
  scanf("%d%d",&n,&k);
  long long int ans=1;
  for(int i=1;i<=n;i++){
   ans=(ans*i)%max;
  }
  printf("%lld",ans);
 }
 return 0;
}


#include <stdio.h>

int main()
{
 unsigned int t,k;
 unsigned long long int n,i;
 scanf("%u",&t);
 while(t--)
 {
     scanf("%llu%u",&n,&k);
     i=1;
     while(k--)
     {
         i=i*n%1000000007;
     }
printf("%llu",i);
 }

    return 0;
}


#include<stdio.h>
int main(){
  int t;
  scanf("%d",&t);
  while(t--){
    int n,k;
    scanf("%d %d",&n,&k);
    long long int ans = 0;
    for(int i=1; i<=k; i++){
      ans=ans*n;
      ans=ans%1000000007;
    }
    printf("%lld\n",ans);
  }
  return 0;
}


#include<stdio.h>
int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        int n, k, c=1;
        scanf("%d %d", &n, &k);
        while(k--)
            c=c*n;
        printf("%d", c%1000000007);
    }
}


#include<stdio.h>
int main() {
	int t; scanf("%d", &t);
	int mod = 1e9 + 7;
	while (t--) {
		int n, k; scanf("%d%d", &n, &k);
		int ans = 1;
		for (int i = 0; i < k; i++) {
			ans *= n;
			ans %= mod;
		}
		printf("%d\n", ans);
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i,T;
    long long ans=1LL;
    long long mod=(1E9)+7;
    scanf("%d",&T);
    while(T--)
    {
        ans=1LL;
    scanf("%d%d",&n,&k);
    for(i=0;i<k;i++)
    {
        ans=(ans*n)%mod;
    }
    printf("%lld\n",ans);
     }
}


#include <stdio.h>

#define M 1000000007

int min(int a, int b) { return a < b ? a : b; }

int main()
{
     int x,y,z,i,j,k,a,b,c,n,m,t;
     long long res;

     scanf("%d",&t);
     while(t--)
     {
           res = 1;
           scanf("%d %d",&n,&k);
           k = min(n, k);
           for(x = 0; x < k; x++)
               res = (res * n) % M;

           printf("%lld\n",res);
     }
     return 0;
}


#include <stdio.h>
#include <string.h>

#define N	200

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

int vv[N + 1], ff[N + 1], gg[N + 1];

void init(int md) {
	int i;

	ff[0] = gg[0] = 1;
	for (i = 1; i <= N; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - md % i] * (md / i + 1) % md;
		ff[i] = (long long) ff[i - 1] * i % md;
		gg[i] = (long long) gg[i - 1] * vv[i] % md;
	}
}

int main() {
	static int dp[N + 1][N + 1];
	int n, md, a, b, k, l, s, ans;

	scanf("%d%d", &n, &md), init(md);
	ans = 0;
	for (a = 1; a	<= n + 1; a++) {
		for (k = 0; k <= n; k++)
			memset(dp[k], 0, (a + 1) * sizeof *dp[k]);
		dp[0][0] = 1;
		for (b = a; b <= n + 1; b++) {
			for (k = n; k >= 0; k--)
				for (s = 0; s + (n - k) * (b - a) <= a && s + k * a <= a * (b - 1); s++) {
					int x = dp[k][s], k_, s_, lower, upper;

					if (x == 0)
						continue;
					/* l >= 1
					 * k + l <= n
					 * s + l * (b - a) + (n - (k + l)) * (b + 1 - a) <= a
					 * s + l * (b - a) + (k + l) * a <= a * b
					 *
					 * l >= 1
					 * l <= n - k
					 * l >= s + (n - k) * (b + 1 - a) - a
					 * l <= (a * b - s - k * a) / b
					 */
					lower = max(1, s + (n - k) * (b + 1 - a) - a);
					upper = min(n - k, (a * b - s - k * a) / b);
					for (l = lower; l <= upper; l++) {
						k_ = k + l, s_ = s + l * (b - a);
						dp[k_][s_] = (dp[k_][s_] + (long long) dp[k][s] * gg[l]) % md;
					}
				}
			if (b == a)
				dp[0][0] = 0;
		}
		for (s = 0; s <= a; s++)
			ans = (ans + (long long) dp[n][s] * ff[n]) % md;
	}
	printf("%d\n", ans);
	return 0;
}