#include <iostream> #include <algorithm> #include <assert.h> #include <string> using namespace std; long long readInt(long long l,long long r,char endd){ long long x=0; int cnt=0; int fi=-1; bool is_neg=false; while(true){ char g=getchar(); if(g=='-'){ assert(fi==-1); is_neg=true; continue; } if('0'<=g && g<='9'){ x*=10; x+=g-'0'; if(cnt==0){ fi=g-'0'; } cnt++; assert(fi!=0 || cnt==1); assert(fi!=0 || is_neg==false); assert(!(cnt>19 || ( cnt==19 && fi>1) )); } else if(g==endd){ assert(cnt>0); if(is_neg){ x= -x; } assert(l<=x && x<=r); return x; } else { assert(false); } } } string readString(int l,int r,char endd){ string ret=""; int cnt=0; while(true){ char g=getchar(); assert(g!=-1); if(g==endd){ break; } cnt++; ret+=g; } assert(l<=cnt && cnt<=r); return ret; } long long readIntSp(long long l,long long r){ return readInt(l,r,' '); } long long readIntLn(long long l,long long r){ return readInt(l,r,'\n'); } string readStringLn(int l,int r){ return readString(l,r,'\n'); } string readStringSp(int l,int r){ return readString(l,r,' '); } int T; int x,n; int sm_n=0; int need; bool found; int sol[1001001]; void bruteforce(int u){ found=false; for(int i=0;i<(1<<u);i++){ int diff=need; for(int j=0;j<u;j++){ if(j+1==x)continue; if(i & (1<<j)){ diff += j+1; } else { diff -= j+1; } } if(diff == 0){ found=true; for(int j=0;j<u;j++){ if(j+1==x){ sol[j+1] = 2; continue; } if(i & (1<<j)){ sol[j+1] = 0; } else { sol[j+1] = 1; } } break; } } } int main(){ //freopen("02.txt","r",stdin); //freopen("0322.txt","w",stderr); T=readIntLn(1,10000); while(T--){ x=readIntSp(1,1000000); n=readIntLn(2,1000000); assert(x<=n); sm_n+=n; assert(sm_n<=1000000); long long sm = n * 1ll *(n+1)/2 - x; if(sm % 2){ printf("impossible\n"); continue; } sm /=2; long long first= 0, second =0; int hh=10; for(int i=n;i>hh;i--){ if(i == x){ continue; } if(first < second){ sol[i] = 0; first += i; } else { sol[i] = 1; second += i; } } need = first - second; found=false; bruteforce(min(hh,n)); if(!found){ //cerr<<x<< " "<<n<<endl; printf("impossible\n"); continue; } sol[x]=2; for(int i=1;i<=n;i++){ printf("%d",sol[i]); } printf("\n"); } assert(getchar()==-1); }