QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#758039#8825. Puzzle: SummonUESTC_undefined (Yicong Li, Shuaikang Peng, Yike Chen)#AC ✓83ms12336kbC++205.4kb2024-11-17 15:18:272024-11-17 15:18:27

Judging History

This is the latest submission verdict.

  • [2024-11-17 15:18:27]
  • Judged
  • Verdict: AC
  • Time: 83ms
  • Memory: 12336kb
  • [2024-11-17 15:18:27]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define y0 sxxxxx
#define pii pair<int, int>
#define ll long long
#define fi first
#define se second
#define bg begin
namespace IO{

cs int RLEN=1<<22|1;
char ibuf[RLEN],*ib,*ob;
inline char gc(){
    (ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob)?EOF:*ib++;
}
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline ll readll(){
    char ch=gc();
    ll res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline char readchar(){
	char ch=gc();
	while(isspace(ch))ch=gc();
	return ch;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	s[top+1]='\0';return top;
}

}
using IO::read;
using IO::readll;
using IO::readchar;
using IO::readstring;
template <typename tp>
inline void chemx(tp &a, tp b) { (a < b) ? (a = b) : 0; }
template <typename tp>
inline void chemn(tp &a, tp b) { (a > b) ? (a = b) : 0; }


cs int N=200005;

int n;
char s[2][N];

#define poly vector<int>


void Add(poly &a,poly b){
    if(a.size()<b.size())a.resize(b.size());
    for(int i=0;i<b.size();i++){
        a[i]+=b[i];
        if(a[i]>9){
            if(i+1==a.size())a.pb(0);
            a[i+1]+=a[i]/10,a[i]%=10;
        }
    }
    int p=b.size();
    while(p<a.size()&&a[p]>9){
        if(p+1==a.size())a.pb(0);
        a[p+1]+=a[p]/10,a[p]%=10,p++;
    }
    
}
bool comp(poly a,poly b){// a<b
    if(a.size()<b.size())return 1;
    if(a.size()>b.size())return 0;
    for(int i=(int)a.size()-1;~i;i--){
        if(a[i]!=b[i]){
            return a[i]<b[i];
        }
    }
    return 0;
}
int lx,rx,ly,ry;
int tmp[N];
poly calc(int l,int r){
    for(int i=1;i<=2*n;i++)tmp[i]=0;
    for(int i=1;i<=n;i++){
        if((i>l&&i<=r)||(i<=l&&i>r)){
            int ps=2*i-1+(i>l);
            if(s[1][ps]!='1')tmp[ps]=1;
            else tmp[ps]=0;
            ps=2*i-1+(i>r);
            if(s[1][ps]!='2')tmp[ps]=2;
            else tmp[ps]=0;            
        }
        else{
            int ps=2*i-1+(i>l);
        //    cout<<i<<" "<<ps<<'\n';
            if(s[0][ps]=='1'||s[1][ps]=='2'){
                tmp[ps]=1;
            }
            else tmp[ps]=2;
        }
    }
  //  cout<<l<<" "<<r<<'\n';
  // for(int i=1;i<=2*n;i++)cout<<tmp[i];puts("");
    poly res(1,0);
    poly now;
    for(int i=1;i<=2*n;i++){
        if(tmp[i]==0){
            if(now.size()){
                reverse(now.begin(),now.end());
                Add(res,now);
                now.clear();
            }
        }
        else{
            now.pb(tmp[i]);
        }
    }
    if(now.size()){
        reverse(now.begin(),now.end());
        Add(res,now);
        now.clear();
    }    
    return res;
}
char ss[2][N];
void get_ans(int l,int r){
  //  cout<<l<<" "<<r<<'\n';
    for(int j=0;j<2;j++){
        for(int i=1;i<=2*n;i++)ss[j][i]='0';
        ss[j][2*n+1]='\0';
    }
    for(int i=1;i<=n;i++){
        if((i>l&&i<=r)||(i<=l&&i>r)){
            int ps=2*i-1+(i>l);
            if(s[1][ps]!='1')ss[0][ps]='1',ss[1][ps]='0';
            else ss[0][ps]='0',ss[1][ps]='1';
            ps=2*i-1+(i>r);
            if(s[1][ps]!='2')ss[0][ps]='2',ss[1][ps]='0';
            else ss[0][ps]='0',ss[1][ps]='2';          
        }
        else{
            int ps=2*i-1+(i>l);
            if(s[0][ps]=='1'||s[1][ps]=='2'){
                ss[0][ps]='1';
                ss[1][ps]='2';

            }
            else ss[0][ps]='2',ss[1][ps]='1';
        }
    }    
    for(int i=0;i<2;i++)cout<<(ss[i]+1)<<'\n';
}
void write(poly x){
    for(int i=(int)x.size()-1;~i;i--)cout<<x[i];
    puts("");
}
void solve(){
    n=read();
    readstring(s[0]);
    readstring(s[1]);
    lx=ly=-1;
    rx=ry=n+1;
    for(int i=n;i;i--){
        int cnt1=0,cnt2=0;
        for(int j=0;j<2;j++)
        for(int k=0;k<2;k++){
            if(s[j][i*2-1+k]=='1'){
                cnt1++;
                if(k==0)lx=max(lx,i);
                else rx=min(rx,i);
            }
            if(s[j][i*2-1+k]=='2'){
                cnt2++;
                if(k==0)ly=max(ly,i);
                else ry=min(ry,i);
            }
        }
        if(cnt1>1||cnt2>1){puts("impossible");return;}
    }
  //  cout<<lx<<" "<<ly<<" "<<rx<<" "<<ry<<'\n';
    for(int i=1;i<=2*n;i++)
    for(int j=0;j<2;j++)if(s[j][i]!='?'){
        if(i>1){
            for(int k=0;k<2;k++)if(s[k][i-1]==s[j][i]){
                puts("impossible");return;
            }
        }
        if(i<2*n){
            for(int k=0;k<2;k++)if(s[k][i+1]==s[j][i]){
                puts("impossible");return;
            }            
        }
    }
    if(lx>rx||ly>ry){
        puts("impossible");return;
    }
    poly f1=calc(lx,ry-1);
    poly f2=calc(rx-1,ly);
    if(comp(f1,f2)){
        write(f2);
        get_ans(rx-1,ly);
    }
    else{
        write(f1);
        get_ans(lx,ry-1);
    }
}

int main() {
	#ifdef Stargazer
	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	#endif
	int T=read();
    while(T--){
        solve();
    }
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3496kb

input:

5
2
?1??
??1?
4
1???????
???2???2
5
??????????
??????????
6
1212????????
????????1212
7
?2?1?????1?2??
?????1???????2

output:

impossible
242
12101210
00020002
2121212121
2121212121
0000000000
12121212
121212120000
000000001212
21
12010202010201
00020101020102

result:

ok all is correct (5 test cases)

Test #2:

score: 0
Accepted
time: 8ms
memory: 8332kb

input:

1
100000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #3:

score: 0
Accepted
time: 4ms
memory: 8348kb

input:

1
100000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #4:

score: 0
Accepted
time: 14ms
memory: 8328kb

input:

1
100000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #5:

score: 0
Accepted
time: 8ms
memory: 8324kb

input:

1
100000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (1 test case)

Test #6:

score: 0
Accepted
time: 6ms
memory: 6608kb

input:

2
49999
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #7:

score: 0
Accepted
time: 8ms
memory: 6580kb

input:

2
49999
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #8:

score: 0
Accepted
time: 5ms
memory: 6620kb

input:

2
49999
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #9:

score: 0
Accepted
time: 6ms
memory: 8480kb

input:

2
49999
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (2 test cases)

Test #10:

score: 0
Accepted
time: 69ms
memory: 7652kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212123333333333333333333333333333333333333333333333333...

result:

ok all is correct (200 test cases)

Test #11:

score: 0
Accepted
time: 74ms
memory: 7712kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #12:

score: 0
Accepted
time: 31ms
memory: 7760kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #13:

score: 0
Accepted
time: 32ms
memory: 7744kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #14:

score: 0
Accepted
time: 20ms
memory: 7664kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (200 test cases)

Test #15:

score: 0
Accepted
time: 19ms
memory: 7808kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #16:

score: 0
Accepted
time: 71ms
memory: 7784kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (200 test cases)

Test #17:

score: 0
Accepted
time: 73ms
memory: 7928kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #18:

score: 0
Accepted
time: 27ms
memory: 7712kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #19:

score: 0
Accepted
time: 31ms
memory: 8136kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
2121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #20:

score: 0
Accepted
time: 21ms
memory: 7992kb

input:

200
5000
???2???????????????????????????????????????1???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (200 test cases)

Test #21:

score: 0
Accepted
time: 21ms
memory: 7924kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #22:

score: 0
Accepted
time: 64ms
memory: 7732kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #23:

score: 0
Accepted
time: 69ms
memory: 7764kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #24:

score: 0
Accepted
time: 28ms
memory: 7692kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #25:

score: 0
Accepted
time: 29ms
memory: 7964kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #26:

score: 0
Accepted
time: 21ms
memory: 7916kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
2121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #27:

score: 0
Accepted
time: 26ms
memory: 7996kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
121212121212121212121212121212121212121212121214242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424...

result:

ok all is correct (100 test cases)

Test #28:

score: 0
Accepted
time: 71ms
memory: 7780kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #29:

score: 0
Accepted
time: 68ms
memory: 7784kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #30:

score: 0
Accepted
time: 32ms
memory: 7788kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121213333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333...

result:

ok all is correct (200 test cases)

Test #31:

score: 0
Accepted
time: 30ms
memory: 7728kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (100 test cases)

Test #32:

score: 0
Accepted
time: 25ms
memory: 7900kb

input:

200
5000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (200 test cases)

Test #33:

score: 0
Accepted
time: 19ms
memory: 7760kb

input:

100
10000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (100 test cases)

Test #34:

score: 0
Accepted
time: 69ms
memory: 9448kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #35:

score: 0
Accepted
time: 75ms
memory: 11716kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #36:

score: 0
Accepted
time: 33ms
memory: 8848kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #37:

score: 0
Accepted
time: 32ms
memory: 11048kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #38:

score: 0
Accepted
time: 18ms
memory: 8500kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
2121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #39:

score: 0
Accepted
time: 16ms
memory: 8092kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible

result:

ok all is correct (10 test cases)

Test #40:

score: 0
Accepted
time: 83ms
memory: 9768kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #41:

score: 0
Accepted
time: 64ms
memory: 11344kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #42:

score: 0
Accepted
time: 39ms
memory: 9428kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #43:

score: 0
Accepted
time: 25ms
memory: 11108kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
2121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #44:

score: 0
Accepted
time: 30ms
memory: 8424kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #45:

score: 0
Accepted
time: 17ms
memory: 9496kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #46:

score: 0
Accepted
time: 70ms
memory: 9912kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #47:

score: 0
Accepted
time: 69ms
memory: 11788kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #48:

score: 0
Accepted
time: 36ms
memory: 9212kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #49:

score: 0
Accepted
time: 35ms
memory: 10896kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (10 test cases)

Test #50:

score: 0
Accepted
time: 20ms
memory: 9136kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #51:

score: 0
Accepted
time: 20ms
memory: 8092kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible

result:

ok all is correct (10 test cases)

Test #52:

score: 0
Accepted
time: 72ms
memory: 9488kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...

result:

ok all is correct (20 test cases)

Test #53:

score: 0
Accepted
time: 70ms
memory: 12336kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #54:

score: 0
Accepted
time: 26ms
memory: 8840kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #55:

score: 0
Accepted
time: 34ms
memory: 10668kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #56:

score: 0
Accepted
time: 23ms
memory: 9028kb

input:

20
50000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (20 test cases)

Test #57:

score: 0
Accepted
time: 25ms
memory: 9304kb

input:

10
100000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

impossible
impossible
21212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result:

ok all is correct (10 test cases)

Test #58:

score: 0
Accepted
time: 28ms
memory: 4364kb

input:

100000
1
??
2?
1
??
12
1
1?
2?
1
1?
??
1
1?
1?
1
1?
2?
1
?2
?1
1
?1
??
1
1?
??
1
??
?1
1
??
12
1
??
21
1
??
2?
1
1?
??
1
1?
??
1
?1
?2
1
2?
2?
1
??
?1
1
21
??
1
??
?1
1
2?
1?
1
?2
??
1
2?
2?
1
2?
2?
1
??
?1
1
1?
??
1
?2
?2
1
2?
?1
1
2?
1?
1
2?
1?
1
2?
1?
1
??
2?
1
??
12
1
1?
?2
1
??
?1
1
2?
?1
1
??
...

output:

1
01
20
0
00
12
1
10
20
12
12
00
impossible
1
10
20
2
02
01
21
21
00
12
12
00
2
20
01
0
00
12
0
00
21
1
01
20
12
12
00
12
12
00
1
01
02
impossible
2
20
01
21
21
00
2
20
01
2
20
10
12
12
00
impossible
impossible
2
20
01
12
12
00
impossible
2
20
01
2
20
10
2
20
10
2
20
10
1
01
20
0
00
12
1
10
02
2
20
...

result:

ok all is correct (100000 test cases)

Test #59:

score: 0
Accepted
time: 83ms
memory: 7764kb

input:

20000
50
?????????????????????????2??????????????????????????????????????????????????????????????????????????
?????2??????????????????????????????????????????????????????????????????????????????????????????????
50
?????????????????????????????2??????2?????????????????????????????????????????????????...

output:

1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212133333
1212101212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212
0000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
imp...

result:

ok all is correct (20000 test cases)

Test #60:

score: 0
Accepted
time: 11ms
memory: 4360kb

input:

100000
1
2?
2?
1
?2
?2
1
21
??
1
21
21
1
2?
2?
1
21
21
1
?1
?1
1
?2
?2
1
?2
?2
1
2?
2?
1
?1
?1
1
12
12
1
1?
??
1
?1
?1
1
?1
?1
1
12
?2
1
?2
?2
1
1?
2?
1
1?
2?
1
12
12
1
?2
?2
1
2?
1?
1
12
?2
1
1?
2?
1
?2
?2
1
21
2?
1
?1
?1
1
2?
1?
1
2?
21
1
?2
?2
1
?2
?1
1
12
1?
1
?1
?1
1
12
12
1
12
12
1
1?
1?
1
?2
...

output:

impossible
impossible
21
21
00
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
12
12
00
impossible
impossible
impossible
impossible
1
10
20
1
10
20
impossible
impossible
2
20
10
impossible
1
10
20
impossible
impossible
impossible
2
20
10
impossible
...

result:

ok all is correct (100000 test cases)

Test #61:

score: 0
Accepted
time: 41ms
memory: 7780kb

input:

20000
50
???????????????????????1??????????????????????????????1?????????????????????????????????????????????
???????????????????????????????1??????????????2???????????????????????1???????????????1?????????????
50
?????????1?????????????????????????1???1??????????????????????????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
21212121212121212196
2020202020202020202020102020202020202020201020202020202020201020202020202020102121212121212121212101
1010101010101010101010201010101010101010102010101010101010102010101010101010200000000000000000000020
impossible
21212121308...

result:

ok all is correct (20000 test cases)

Test #62:

score: 0
Accepted
time: 10ms
memory: 4400kb

input:

100000
1
21
21
1
12
12
1
2?
1?
1
1?
2?
1
21
21
1
12
12
1
12
1?
1
1?
2?
1
21
21
1
2?
21
1
?2
?2
1
?2
?2
1
12
12
1
12
12
1
21
21
1
2?
1?
1
21
21
1
2?
2?
1
2?
2?
1
2?
1?
1
1?
1?
1
?1
?2
1
21
21
1
?2
?2
1
?1
?1
1
12
12
1
21
21
1
2?
2?
1
21
21
1
21
21
1
2?
1?
1
1?
1?
1
1?
2?
1
21
?1
1
?2
?2
1
21
21
1
?1
...

output:

impossible
impossible
2
20
10
1
10
20
impossible
impossible
impossible
1
10
20
impossible
impossible
impossible
impossible
impossible
impossible
impossible
2
20
10
impossible
impossible
impossible
2
20
10
impossible
1
01
02
impossible
impossible
impossible
impossible
impossible
impossible
impossible...

result:

ok all is correct (100000 test cases)

Test #63:

score: 0
Accepted
time: 23ms
memory: 7592kb

input:

20000
50
???????1???????????????????2?2???????????????2?????????????1????????????????????????2???????????????
???????????????????????????2?????????????????????????1?????????????1??????2???????????????1?????????
50
?????????????????????????????????1?????????????????2???1????1?????????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
21212121212201
212121212121210101020...

result:

ok all is correct (20000 test cases)

Test #64:

score: 0
Accepted
time: 28ms
memory: 6136kb

input:

100000
1
?2
1?
1
2?
?1
1
?1
?1
1
2?
??
1
?2
?1
1
??
21
1
?1
2?
1
??
2?
1
2?
?1
1
?2
??
1
21
??
1
??
2?
1
??
21
1
??
21
1
1?
?2
1
21
??
1
2?
1?
1
21
??
1
?2
?1
1
2?
??
1
??
21
1
?1
?2
1
??
2?
1
2?
??
1
21
??
1
1?
??
1
?2
??
1
??
?2
1
?1
2?
1
?2
1?
1
?2
?2
1
?1
?1
1
??
21
1
2?
??
1
1?
2?
1
1?
1?
1
1?
...

output:

2
02
10
2
20
01
impossible
21
21
00
2
02
01
0
00
21
1
01
20
1
01
20
2
20
01
12
12
00
21
21
00
1
01
20
0
00
21
0
00
21
1
10
02
21
21
00
2
20
10
21
21
00
2
02
01
21
21
00
0
00
21
1
01
02
1
01
20
21
21
00
21
21
00
12
12
00
12
12
00
1
01
02
1
01
20
2
02
10
impossible
impossible
0
00
21
21
21
00
1
10
20
...

result:

ok all is correct (100000 test cases)

Test #65:

score: 0
Accepted
time: 83ms
memory: 7612kb

input:

20000
50
????????????????????????????????????????????????????????????????????????????????????????????????????
???????????1???????????????????????????????????????????????????????????????????????????2????????????
50
?????????????????2????????????????????????????????????????????????????????????????????...

output:

21212121212121212121212121212121212121212121212121212121212121233333333346
2121212121202121212121212121212121212121212121212121212121212121212121212121212121212101020202020202
0000000000010000000000000000000000000000000000000000000000000000000000000000000000000002010101010101
21212121212121212121212...

result:

ok all is correct (20000 test cases)

Test #66:

score: 0
Accepted
time: 14ms
memory: 4300kb

input:

100000
1
2?
2?
1
21
2?
1
2?
1?
1
12
??
1
1?
2?
1
2?
1?
1
?1
?1
1
?2
12
1
?2
?2
1
21
21
1
21
21
1
21
2?
1
?2
?1
1
2?
2?
1
12
12
1
2?
2?
1
2?
21
1
21
?1
1
?2
?2
1
2?
1?
1
?1
?1
1
21
21
1
?2
?2
1
12
12
1
1?
12
1
21
?1
1
?2
?1
1
?2
12
1
?1
21
1
21
?1
1
?1
?2
1
2?
2?
1
2?
2?
1
21
?1
1
?1
?1
1
21
21
1
21
...

output:

impossible
impossible
2
20
10
12
12
00
1
10
20
2
20
10
impossible
impossible
impossible
impossible
impossible
impossible
2
02
01
impossible
impossible
impossible
impossible
impossible
impossible
2
20
10
impossible
impossible
impossible
impossible
impossible
impossible
2
02
01
impossible
impossible
i...

result:

ok all is correct (100000 test cases)

Test #67:

score: 0
Accepted
time: 37ms
memory: 7496kb

input:

20000
50
?????????2????????????????????????????????????????????????????????2?????????1???????????????????????
??????????????????????????????1?2???????????????????????????????????????????????1???????????????????
50
?????????????????????????????????1????????????????????????????2???2???????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
233
2020202020202020202020102020202020202020202020202020202020201020202020202020202020202020202010210121
1010101010101010101010201010101010101010101010101010101010102010101010101010101010101010101020002000
impossible
212121...

result:

ok all is correct (20000 test cases)

Test #68:

score: 0
Accepted
time: 10ms
memory: 4360kb

input:

100000
1
?2
?2
1
2?
2?
1
12
12
1
21
21
1
21
21
1
?2
?1
1
?1
?2
1
1?
12
1
?1
?2
1
12
12
1
1?
2?
1
?1
?2
1
21
21
1
?1
?1
1
21
21
1
12
12
1
2?
1?
1
?2
?1
1
?1
?1
1
1?
12
1
?1
?2
1
12
12
1
?2
?2
1
1?
2?
1
?2
?2
1
21
21
1
21
21
1
12
12
1
21
21
1
21
21
1
?1
?2
1
21
21
1
21
21
1
21
21
1
1?
2?
1
21
21
1
21
...

output:

impossible
impossible
impossible
impossible
impossible
2
02
01
1
01
02
impossible
1
01
02
impossible
1
10
20
1
01
02
impossible
impossible
impossible
impossible
2
20
10
2
02
01
impossible
impossible
1
01
02
impossible
impossible
1
10
20
impossible
impossible
impossible
impossible
impossible
impossib...

result:

ok all is correct (100000 test cases)

Test #69:

score: 0
Accepted
time: 23ms
memory: 7608kb

input:

20000
50
????????????1??????????????????????????????????22?????????????1???????????????????????????????2?????
1???????1????????????????????2?2??????????????????????????1???????????????2???????????2?????????????
50
???????2?????????????????????2?????????????1????????????????????????????????????????1?...

output:

impossible
impossible
impossible
impossible
1226363636421
2020202010202010202020102020202020201020102020202020202020201020212121212101212121212121012121212121
1010101020101020101010201010101010102010201010101010101010102010000000000020000000000000200000000000
impossible
12121212121213333333333333545...

result:

ok all is correct (20000 test cases)

Test #70:

score: 0
Accepted
time: 24ms
memory: 4360kb

input:

100000
1
?1
?1
1
1?
1?
1
2?
1?
1
??
?2
1
?1
?2
1
?1
??
1
?2
??
1
1?
??
1
2?
2?
1
1?
??
1
2?
??
1
?2
?1
1
2?
?1
1
2?
2?
1
??
2?
1
2?
2?
1
?2
?2
1
2?
??
1
??
2?
1
?1
2?
1
2?
?1
1
??
?1
1
2?
?1
1
??
21
1
1?
1?
1
2?
2?
1
1?
??
1
2?
2?
1
??
1?
1
?2
??
1
2?
2?
1
1?
1?
1
?1
?1
1
?2
?2
1
??
?2
1
?2
?2
1
2?
...

output:

impossible
impossible
2
20
10
1
01
02
1
01
02
21
21
00
12
12
00
12
12
00
impossible
12
12
00
21
21
00
2
02
01
2
20
01
impossible
1
01
20
impossible
impossible
21
21
00
1
01
20
1
01
20
2
20
01
2
20
01
2
20
01
0
00
21
impossible
impossible
12
12
00
impossible
2
20
10
12
12
00
impossible
impossible
imp...

result:

ok all is correct (100000 test cases)

Test #71:

score: 0
Accepted
time: 83ms
memory: 7536kb

input:

20000
50
??????????????????????????????????????????????????????????????????????1?????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????2???
50
??????????????????????????????????????????????????????????????????????????????????????...

output:

212121212121212121212313
2020202020202020202020202020202020202020202020202020202020202020202020102121212121212121212121210121
1010101010101010101010101010101010101010101010101010101010101010101010200000000000000000000000002000
12121212121212121212121213345454545454545454545454
1212121212121212121212...

result:

ok all is correct (20000 test cases)

Test #72:

score: 0
Accepted
time: 9ms
memory: 5852kb

input:

100000
1
?1
?1
1
2?
21
1
1?
2?
1
?1
?2
1
?1
?2
1
21
21
1
21
?1
1
1?
1?
1
12
??
1
2?
21
1
21
2?
1
1?
1?
1
1?
2?
1
?2
12
1
?2
?2
1
1?
2?
1
2?
2?
1
12
12
1
?1
?2
1
1?
12
1
?2
?1
1
?1
?2
1
1?
2?
1
?2
?1
1
?1
?1
1
1?
1?
1
1?
?2
1
1?
1?
1
1?
2?
1
21
21
1
?2
?2
1
21
21
1
?2
?1
1
21
2?
1
2?
1?
1
?2
?2
1
1?
...

output:

impossible
impossible
1
10
20
1
01
02
1
01
02
impossible
impossible
impossible
12
12
00
impossible
impossible
impossible
1
10
20
impossible
impossible
1
10
20
impossible
impossible
1
01
02
impossible
2
02
01
1
01
02
1
10
20
2
02
01
impossible
impossible
1
10
02
impossible
1
10
20
impossible
impossib...

result:

ok all is correct (100000 test cases)

Test #73:

score: 0
Accepted
time: 37ms
memory: 7600kb

input:

20000
50
?????????2???2???????2??????????????????????????????????????????????2???????2???????????????????????
????????????????????????????????????????????????????????????????????????????????1???????????????????
50
?????????2?????????????????1??????????????????????????????????????????????????????????...

output:

impossible
impossible
214242424242424242500
2121212121212121212021212121212121212121202102020201020202020202020202020202020202020202020202020202
0000000000000000000100000000000000000000010001010102010101010101010101010101010101010101010101010101
impossible
2121212121295
21212121212120010202020202020...

result:

ok all is correct (20000 test cases)

Test #74:

score: 0
Accepted
time: 8ms
memory: 4352kb

input:

100000
1
12
?2
1
?1
?1
1
12
12
1
?2
?2
1
21
21
1
2?
1?
1
21
21
1
21
21
1
21
21
1
2?
1?
1
?2
?1
1
21
21
1
21
21
1
21
21
1
2?
1?
1
?1
?2
1
21
21
1
12
12
1
21
21
1
2?
2?
1
21
21
1
12
12
1
?1
?1
1
2?
1?
1
12
12
1
2?
2?
1
21
21
1
12
1?
1
12
12
1
?2
12
1
12
12
1
2?
2?
1
21
21
1
?2
?2
1
12
12
1
?1
?1
1
?2
...

output:

impossible
impossible
impossible
impossible
impossible
2
20
10
impossible
impossible
impossible
2
20
10
2
02
01
impossible
impossible
impossible
2
20
10
1
01
02
impossible
impossible
impossible
impossible
impossible
impossible
impossible
2
20
10
impossible
impossible
impossible
impossible
impossible...

result:

ok all is correct (100000 test cases)

Test #75:

score: 0
Accepted
time: 19ms
memory: 7828kb

input:

20000
50
???1???1????????????????2?????????????????????2?????????????????2?????????????????????????????1?????
????????????????2?????????????????????????????????2????????????????1????2???????????????????????????
50
???????????????????????1????????????????2???????????????????????????????????????1?????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
2121212121212142426363636363670
2020202020202020101020202020202020200212121212121202121212121212121212121212121212021212121212121212
10101010101010102020101010101010101010000000000000100000000000000000...

result:

ok all is correct (20000 test cases)

Test #76:

score: 0
Accepted
time: 28ms
memory: 4520kb

input:

100000
1
2?
2?
1
2?
??
1
??
?2
1
2?
?1
1
2?
1?
1
??
2?
1
21
??
1
?1
?2
1
2?
2?
1
2?
?1
1
1?
1?
1
1?
1?
1
??
12
1
1?
2?
1
2?
1?
1
?2
?2
1
1?
?2
1
1?
?2
1
?1
??
1
2?
2?
1
1?
?2
1
1?
?2
1
2?
??
1
2?
1?
1
12
??
1
?2
?2
1
?2
1?
1
??
1?
1
12
??
1
1?
1?
1
??
21
1
?1
?2
1
2?
1?
1
??
1?
1
??
?1
1
1?
?2
1
?1
...

output:

impossible
21
21
00
1
01
02
2
20
01
2
20
10
1
01
20
21
21
00
1
01
02
impossible
2
20
01
impossible
impossible
0
00
12
1
10
20
2
20
10
impossible
1
10
02
1
10
02
21
21
00
impossible
1
10
02
1
10
02
21
21
00
2
20
10
12
12
00
impossible
2
02
10
2
20
10
12
12
00
impossible
0
00
21
1
01
02
2
20
10
2
20
1...

result:

ok all is correct (100000 test cases)

Test #77:

score: 0
Accepted
time: 83ms
memory: 7836kb

input:

20000
50
????????????????????????????????????????????????????????????1???????????????????1???????????????????
????????????????????????????????????????????????????????????????????????????????????????????????????
50
??????????????????????????????????????????????????????????????????????????????????????...

output:

1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212
1212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok all is correct (20000 test cases)

Test #78:

score: 0
Accepted
time: 11ms
memory: 6352kb

input:

100000
1
?1
?2
1
21
21
1
?2
?2
1
2?
2?
1
1?
2?
1
21
?1
1
?1
?1
1
21
2?
1
12
12
1
1?
2?
1
?2
?2
1
21
21
1
?2
?1
1
1?
1?
1
?2
1?
1
?2
12
1
12
1?
1
1?
1?
1
2?
1?
1
12
1?
1
12
12
1
2?
2?
1
21
?1
1
21
?1
1
1?
1?
1
?2
12
1
2?
1?
1
?1
?1
1
1?
2?
1
?1
21
1
?1
?2
1
?2
?1
1
2?
1?
1
12
12
1
2?
1?
1
12
1?
1
?2
...

output:

1
01
02
impossible
impossible
impossible
1
10
20
impossible
impossible
impossible
impossible
1
10
20
impossible
impossible
2
02
01
impossible
2
02
10
impossible
impossible
impossible
2
20
10
impossible
impossible
impossible
impossible
impossible
impossible
impossible
2
20
10
impossible
1
10
20
impos...

result:

ok all is correct (100000 test cases)

Test #79:

score: 0
Accepted
time: 42ms
memory: 7836kb

input:

20000
50
???1?????2???????????????????????????????????????????2????????????????????????????????????????2?????
?????????1????????????????????????????????????????????????????????????2?????????????????????????????
50
???????????????????1??????????????????????????????????????????????????????????????????...

output:

impossible
impossible
1212121212121224263659699092120
2121212121202121212121212101212021212120212121212101212121212121212101212121212121212121212121212121
0000000000010000000000000020000100000001000000000020000000000000000020000000000000000000000000000000
impossible
1214242424242424242424293
2020202...

result:

ok all is correct (20000 test cases)

Test #80:

score: 0
Accepted
time: 13ms
memory: 4260kb

input:

100000
1
2?
2?
1
21
21
1
2?
2?
1
2?
1?
1
21
21
1
1?
1?
1
21
21
1
?1
?1
1
21
21
1
?1
?2
1
2?
1?
1
2?
1?
1
?1
?1
1
21
21
1
2?
1?
1
1?
1?
1
2?
1?
1
21
21
1
21
?1
1
12
12
1
12
12
1
12
12
1
21
21
1
1?
1?
1
12
12
1
2?
1?
1
2?
2?
1
21
21
1
2?
2?
1
?1
?2
1
21
21
1
1?
12
1
2?
2?
1
?2
?2
1
21
21
1
12
12
1
21
...

output:

impossible
impossible
impossible
2
20
10
impossible
impossible
impossible
impossible
impossible
1
01
02
2
20
10
2
20
10
impossible
impossible
2
20
10
impossible
2
20
10
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
2
20
10
impossible
impossible
impossible
1
...

result:

ok all is correct (100000 test cases)

Test #81:

score: 0
Accepted
time: 28ms
memory: 7800kb

input:

20000
50
?1???????1????????????????????2?????????????????????????????????????2???????????????????????????????
?2?????????????1???1????????????????????????????????????????????????1???2?????????????1???????1?????
50
???????????????????????2??????????????????2???????2??????????????1????????????????????...

output:

impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
impossible
2121212242424365758909112...

result:

ok all is correct (20000 test cases)

Extra Test:

score: 0
Extra Test Passed