QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#699112#3505. FlightsCrysfly100 ✓9ms4752kbC++2012.4kb2024-11-02 01:21:002024-11-02 01:21:04

Judging History

你现在查看的是最新测评结果

  • [2024-11-02 01:21:04]
  • 评测
  • 测评结果:100
  • 用时:9ms
  • 内存:4752kb
  • [2024-11-02 01:21:00]
  • 提交

Ali

// what is matter? never mind. 
#include"Ali.h"
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define ull unsigned long long
//#define int long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	return f?-x:x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 200005
#define inf 0x3f3f3f3f

const int fa6[11][6]={
	{-1, 0, 1, 1, 2, 3},
	{-1, 0, 1, 1, 2, 2},
	{-1, 0, 1, 1, 2, 4},
	{-1, 0, 1, 2, 3, 4},
	{-1, 0, 1, 2, 3, 3},
	{-1, 0, 0, 1, 2, 3},
	{-1, 0, 0, 1, 1, 2},
	{-1, 0, 0, 1, 1, 3},
	{-1, 0, 0, 1, 3, 4},
	{-1, 0, 1, 2, 2, 3},
	{-1, 0, 0, 1, 3, 3}
};
const int fa7[5][7]={
	{-1, 0, 1, 1, 2, 3, 5},
    {-1, 0, 1, 1, 2, 2, 4},
    {-1, 0, 1, 2, 3, 3, 4},
    {-1, 0, 0, 1, 1, 2, 3},
    {-1, 0, 0, 1, 3, 3, 4}
};
const int f6in7[11]={0,1,1,2,2,3,3,3,4,4,4};

bool is_done;

typedef vector<array<int,2>> tree;
vector<tree>tre[16];
vector<vi>fa14;

int U(int x,int y){
	return x==-1?x:x+y;
}
tree U(tree a,int b){
	for(auto&t:a) t[0]=U(t[0],b),t[1]=U(t[1],b);
	return a;
}
void operator +=(tree &a,tree b){
	b=U(b,a.size());
	for(auto t:b) a.pb(t);
}
int fa[16],dep[16],id[16];

bool chk(tree &a,tree &b,int u,int v){
	if(u==-1)return 1;
	if(v==-1)return 0;
	if(chk(a,b,a[u][0],b[v][0]) && chk(a,b,a[u][1],b[v][1])) return 1;
	if(chk(a,b,a[u][0],b[v][1]) && chk(a,b,a[u][1],b[v][0])) return 1;
	return 0;
}
void getid(tree &a,tree &b,int u,int v){
	if(v==-1||u==-1)return;
	id[u]=v;
	if(chk(a,b,a[u][0],b[v][0]) && chk(a,b,a[u][1],b[v][1])){
		getid(a,b,a[u][0],b[v][0]),getid(a,b,a[u][1],b[v][1]);
		return;
	}
	if(chk(a,b,a[u][0],b[v][1]) && chk(a,b,a[u][1],b[v][0])){
		getid(a,b,a[u][0],b[v][1]),getid(a,b,a[u][1],b[v][0]);
		return;
	}
	assert(0);
}
void print(tree &a){
	cout<<"n: "<<a.size()<<"\n";
	For(i,0,a.size()-1)cout<<a[i][0]<<" "<<a[i][1]<<"\n";
}
bool can[35][35];

struct Map{
	map<vi,int>mp; int sz;
	vector<vi>vec;
	int id(vi o){
		if(!mp.count(o)) vec.pb(o),mp[o]=sz++;
		return mp[o];
	}
	int Q(int i,int j){return vec[i][j];}
}ds,vds;

vi bfs(tree &ch,vi &fa,int st){
	int n=ch.size(); vi dis(n);
	For(i,0,n-1)dis[i]=-1; dis[st]=0;
	queue<int>q; q.push(st);
	while(q.size()){
		int u=q.front(); q.pop();
		for(int v:{fa[u],ch[u][0],ch[u][1]}) 
			if(v!=-1 && dis[v]==-1) {
				dis[v]=dis[u]+1;
				q.push(v);
			}
	}
	return dis;
}

int typd[35][35];

void init_tree()
{
	if(is_done)return; is_done=1;
	//gen every 1-13-tree
	tre[1].pb({{-1,-1}});
	For(n,2,13){
		for(auto ch:tre[n-1]){
			tree t={{1,-1}};
			t+=ch;
			tre[n].pb(t);
		}
		For(i,1,n-2) if(i<7 && n-i-1<7){
			for(auto tl:tre[i]) for(auto tr:tre[n-i-1]){
				tree t={{1,i+1}};
				t+=tl; t+=tr;
				tre[n].pb(t);
			}
		}
//		cout<<"siz "<<n<<" "<<tre[n].size()<<"\n";
	}
	//gen every 14-tree
	For(i,0,10){
		For(j,f6in7[i],4){
			fa[0]=-1,dep[0]=0;
			For(u,0,5) fa[u+1]=U(fa6[i][u],1);
			For(u,0,6) fa[u+7]=U(fa7[j][u],7);
			For(u,1,13) dep[u]=dep[fa[u]]+1;
			int idx=0;
			For(d,0,13) For(u,0,13) if(dep[u]==d) id[u]=idx++;
			vi ft(14,-1);
			For(u,1,13) ft[id[u]]=id[fa[u]];
			tree t(14,{-1,-1});
			For(u,1,13) t[ft[u]][t[ft[u]][0]!=-1]=u;
			tre[14].pb(t);
			fa14.pb(ft);
		}
	}
//	cout<<"siz14 "<<fa14.size()<<"\n";
	// mark all tree
	For(n,7,13){
		for(auto ch:tre[n]){
			bool ok=0;
			For(t,0,27){
				if(chk(ch,tre[14][t],0,0)){
					ok=1;
					getid(ch,tre[14][t],0,0);
					For(i,0,n-1) if(ch[i][1]==-1) can[t][id[i]]=1;
					break;
				}
			}
		}
	}
//	cout<<"mark_done\n";
	For(i,0,27){
		can[i][0]=1;
		For(u,0,13) if(can[i][u]) {
			vi now=bfs(tre[14][i],fa14[i],u);
			if(u==0) typd[i][u]=ds.id(now);
			else typd[i][u]=vds.id(now);
		}
	}
	// 21 270
//	cout<<"size: "<<ds.mp.size()<<" "<<vds.mp.size()<<"\n";
}

const int B1=21,B2=270;

namespace Alice{
	string to2(int x){
		string s;
		For(i,1,29) 
			if(x<(1<<i)) {
				Rep(j,i-1,0) s+='0'+(x>>j&1);
				break;
			}
			else x-=(1<<i);
		return s;
	}
	int get2(string s){
		int res=0;
		for(auto c:s)res=res*2+(c&1);
		return res;
	}

	int n;
	vi e[maxn];
	int s,t,mx;
	
	int rt,sz[maxn],dep[maxn],fa[maxn];
	int id[maxn],d1[maxn],d2[maxn],typ[maxn],top[maxn];
	
	void dfsd(int u,int pa,int *d){
		if(pa!=-1) d[u]=d[pa]+1;
		else d[u]=0;
		if(d[u]>mx)mx=d[u],t=u;
		for(int v:e[u])if(v!=pa)dfsd(v,u,d);
	}
	void diams(){
		s=t=0,mx=0,dfsd(s,-1,d1);
		s=t,mx=0,dfsd(s,-1,d1);
		dfsd(t,-1,d2);
	}
	
	vi qwq[maxn];
	vector<vi>bk;
	tree get(int u){
		tree t; t.pb({-1,-1});
		id[u]=0; qwq[u]={u};
		for(int v:e[u]) if(id[v]==-1) {
			int c=(t[0][0]!=-1);
			t[0][c]=t.size();
			tree tv=get(v);
			for(int x:qwq[v]) qwq[u].pb(x),id[x]+=t.size();
			t+=tv;
		}
		return t;
	}
	
	void dfs(int u){
		sz[u]=1;
		for(int v:e[u]){
			fa[v]=u,dep[v]=dep[u]+1;
			e[v].erase(find(ALL(e[v]),u));
			dfs(v);
			sz[u]+=sz[v];
		}
		if(sz[u]>=7 || u==rt){
			tree ch=get(u);
			bool ok=0;
			For(t,0,27){
				if(chk(ch,tre[14][t],0,0)){
					ok=1;
					getid(ch,tre[14][t],0,0);
					for(int x:qwq[u]) id[x]=::id[id[x]],typ[x]=t;
					bk.pb(qwq[u]);
					break;
				}
			}
			assert(ok);
			sz[u]=0;
		}
	}
	
	void Init(int NN,vi U,vi V){
		init_tree();
		n=NN;
		For(i,0,n-1)e[i].clear(); bk.clear();
		For(i,0,n-2){
			int u=U[i],v=V[i];
			e[u].pb(v),e[v].pb(u);
		}
		
		diams();
		rt=-1;
		int mnd=inf;
		For(i,0,n-1)
			if(e[i].size()<=2 && max(d1[i],d2[i])<mnd)
				mnd=max(d1[i],d2[i]),rt=i;
//		rt=0;
//		For(i,0,n-1) if(e[i].size()<=2) rt=i;
		
		For(i,0,n-1) id[i]=-1,typ[i]=-1;
		dep[rt]=0,fa[rt]=-1,dfs(rt);
		
		sort(bk.begin(),bk.end(),[&](vi a,vi b){
			return dep[a[0]]<dep[b[0]];
		});
		For(i,0,SZ(bk)-1){
			top[i]=bk[i][0];
			for(int x:bk[i]) id[x]+=i*14;
		}
		For(i,0,n-1) SetID(i,id[i]);
	}
	int SendA_i(string S){
		int V=get2(S);
		int y=0;
		while((y+1)*(y+2)/2<=V) ++y;
		int x=V-y*(y+1)/2;
		int u=top[x],v=top[y];
		if(x==y) return typ[u];
		
		int idu=0,res=0;
		while(u!=v){
			++res;
			if(mkp(dep[top[id[u]/14]],dep[u]) > mkp(dep[top[id[v]/14]],dep[v]))
				u=fa[u];
			else {
				v=fa[v];
				if(id[v]/14==x){
					idu=id[v]%14;
					break;
				}
			}
		}
		
		int tx=typ[top[x]],ty=typ[top[y]];
		if(!idu){
			int as=(typd[tx][0]*21+typd[ty][0])*10000+res;
			return as+28;
		}
		int as=(typd[tx][idu]*21+typd[ty][0])*10000/2+res;
		return as+28+B1*B1*10000;
	}
	string SendA(string S){
		int ans=SendA_i(S);
	//	cout<<"ans "<<ans<<"\n";
		return to2(ans);
	}
}

void Init(int N, std::vector<int> U, std::vector<int> V){
    Alice::Init(N, U, V);
}

std::string SendA(std::string S){
    return Alice::SendA(S);
}

Benjamin

// what is matter? never mind.
#include"Benjamin.h" 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define ull unsigned long long
//#define int long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	return f?-x:x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 200005
#define inf 0x3f3f3f3f

const int fa6[11][6]={
	{-1, 0, 1, 1, 2, 3},
	{-1, 0, 1, 1, 2, 2},
	{-1, 0, 1, 1, 2, 4},
	{-1, 0, 1, 2, 3, 4},
	{-1, 0, 1, 2, 3, 3},
	{-1, 0, 0, 1, 2, 3},
	{-1, 0, 0, 1, 1, 2},
	{-1, 0, 0, 1, 1, 3},
	{-1, 0, 0, 1, 3, 4},
	{-1, 0, 1, 2, 2, 3},
	{-1, 0, 0, 1, 3, 3}
};
const int fa7[5][7]={
	{-1, 0, 1, 1, 2, 3, 5},
    {-1, 0, 1, 1, 2, 2, 4},
    {-1, 0, 1, 2, 3, 3, 4},
    {-1, 0, 0, 1, 1, 2, 3},
    {-1, 0, 0, 1, 3, 3, 4}
};
const int f6in7[11]={0,1,1,2,2,3,3,3,4,4,4};

bool is_done;

typedef vector<array<int,2>> tree;
vector<tree>tre[16];
vector<vi>fa14;

int U(int x,int y){
	return x==-1?x:x+y;
}
tree U(tree a,int b){
	for(auto&t:a) t[0]=U(t[0],b),t[1]=U(t[1],b);
	return a;
}
void operator +=(tree &a,tree b){
	b=U(b,a.size());
	for(auto t:b) a.pb(t);
}
int fa[16],dep[16],id[16];

bool chk(tree &a,tree &b,int u,int v){
	if(u==-1)return 1;
	if(v==-1)return 0;
	if(chk(a,b,a[u][0],b[v][0]) && chk(a,b,a[u][1],b[v][1])) return 1;
	if(chk(a,b,a[u][0],b[v][1]) && chk(a,b,a[u][1],b[v][0])) return 1;
	return 0;
}
void getid(tree &a,tree &b,int u,int v){
	if(v==-1||u==-1)return;
	id[u]=v;
	if(chk(a,b,a[u][0],b[v][0]) && chk(a,b,a[u][1],b[v][1])){
		getid(a,b,a[u][0],b[v][0]),getid(a,b,a[u][1],b[v][1]);
		return;
	}
	if(chk(a,b,a[u][0],b[v][1]) && chk(a,b,a[u][1],b[v][0])){
		getid(a,b,a[u][0],b[v][1]),getid(a,b,a[u][1],b[v][0]);
		return;
	}
	assert(0);
}
void print(tree &a){
	cout<<"n: "<<a.size()<<"\n";
	For(i,0,a.size()-1)cout<<a[i][0]<<" "<<a[i][1]<<"\n";
}
bool can[35][35];

struct Map{
	map<vi,int>mp; int sz;
	vector<vi>vec;
	int id(vi o){
		if(!mp.count(o)) vec.pb(o),mp[o]=sz++;
		return mp[o];
	}
	int Q(int i,int j){return vec[i][j];}
}ds,vds;

vi bfs(tree &ch,vi &fa,int st){
	int n=ch.size(); vi dis(n);
	For(i,0,n-1)dis[i]=-1; dis[st]=0;
	queue<int>q; q.push(st);
	while(q.size()){
		int u=q.front(); q.pop();
		for(int v:{fa[u],ch[u][0],ch[u][1]}) 
			if(v!=-1 && dis[v]==-1) {
				dis[v]=dis[u]+1;
				q.push(v);
			}
	}
	return dis;
}

int typd[35][35];

void init_tree()
{
	if(is_done)return; is_done=1;
	//gen every 1-13-tree
	tre[1].pb({{-1,-1}});
	For(n,2,13){
		for(auto ch:tre[n-1]){
			tree t={{1,-1}};
			t+=ch;
			tre[n].pb(t);
		}
		For(i,1,n-2) if(i<7 && n-i-1<7){
			for(auto tl:tre[i]) for(auto tr:tre[n-i-1]){
				tree t={{1,i+1}};
				t+=tl; t+=tr;
				tre[n].pb(t);
			}
		}
//		cout<<"siz "<<n<<" "<<tre[n].size()<<"\n";
	}
	//gen every 14-tree
	For(i,0,10){
		For(j,f6in7[i],4){
			fa[0]=-1,dep[0]=0;
			For(u,0,5) fa[u+1]=U(fa6[i][u],1);
			For(u,0,6) fa[u+7]=U(fa7[j][u],7);
			For(u,1,13) dep[u]=dep[fa[u]]+1;
			int idx=0;
			For(d,0,13) For(u,0,13) if(dep[u]==d) id[u]=idx++;
			vi ft(14,-1);
			For(u,1,13) ft[id[u]]=id[fa[u]];
			tree t(14,{-1,-1});
			For(u,1,13) t[ft[u]][t[ft[u]][0]!=-1]=u;
			tre[14].pb(t);
			fa14.pb(ft);
		}
	}
//	cout<<"siz14 "<<fa14.size()<<"\n";
	// mark all tree
	For(n,7,13){
		for(auto ch:tre[n]){
			bool ok=0;
			For(t,0,27){
				if(chk(ch,tre[14][t],0,0)){
					ok=1;
					getid(ch,tre[14][t],0,0);
					For(i,0,n-1) if(ch[i][1]==-1) can[t][id[i]]=1;
					break;
				}
			}
		}
	}
//	cout<<"mark_done\n";
	For(i,0,27){
		can[i][0]=1;
		For(u,0,13) if(can[i][u]) {
			vi now=bfs(tre[14][i],fa14[i],u);
			if(u==0) typd[i][u]=ds.id(now);
			else typd[i][u]=vds.id(now);
		}
	}
	// 21 270
//	cout<<"size: "<<ds.mp.size()<<" "<<vds.mp.size()<<"\n";
}

const int B1=21,B2=270;

namespace Bob{
	string to2(int x){
		string s;
		Rep(i,19,0)s+=('0'+(x>>i&1));
		return s;
	}
	int get2(string s){
		int x=0;
		for(auto c:s)x=x*2+(c&1);
		x+=(1<<s.size())-2;
		return x;
	}
	int n,x,y;
	string SendB(int NN,int X,int Y){
	//	cout<<"sendB "<<X<<" "<<Y<<"\n";
		init_tree(); 
		if(X>Y)swap(X,Y);
		n=NN,x=X,y=Y;
		X/=14,Y/=14; // <=10000/14
		int go=X+Y*(Y+1)/2;
		return to2(go);
	}
	int dis(vi &fa,int u,int v){
		int res=0;
		while(u!=v){
			res++;
			if(u>v) u=fa[u];
			else v=fa[v];
		}
		return res;
	}
	int Answer(string T){
		int V=get2(T);
		if(V<28) return dis(fa14[V],x%14,y%14);
		V-=28;
		if(V<B1*B1*10000){
			int res=V%10000; V/=10000;
			int ty=V%B1; V/=B1;
			int tx=V%B1; V/=B1;
			return ds.Q(tx,x%14)+ds.Q(ty,y%14)+res;
		}
		V-=B1*B1*10000;
		if(1){
			int res=V%5000; V/=5000;
			int ty=V%B1; V/=B1;
			int tx=V%B2; V/=B2;
			return vds.Q(tx,x%14)+ds.Q(ty,y%14)+res;
		}
	}
}

std::string SendB(int N, int X, int Y){
    return Bob::SendB(N, X, Y);
}

int Answer(std::string T){
    return Bob::Answer(T);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 15
Accepted

Test #1:

score: 15
Accepted
time: 6ms
memory: 4708kb

input:

1
2 1 0
0

output:

00000000000000000000
1

input:


output:

1
1

result:

points 1.0 L = 1 (test case 1)

Test #2:

score: 15
Accepted
time: 6ms
memory: 4744kb

input:

1
3 2 1
0

output:

00000000000000000000
2

input:


output:

2
1

result:

points 1.0 L = 1 (test case 1)

Test #3:

score: 15
Accepted
time: 6ms
memory: 4528kb

input:

1
4 2 0
0

output:

00000000000000000000
1

input:


output:

1
1

result:

points 1.0 L = 1 (test case 1)

Test #4:

score: 15
Accepted
time: 3ms
memory: 4712kb

input:

1
5 5 2
01

output:

00000000000000000000
1

input:


output:

1
2

result:

points 1.0 L = 2 (test case 1)

Test #5:

score: 15
Accepted
time: 5ms
memory: 4744kb

input:

1
10000 5406 11734
101011011011111000

output:

01010101111010110111
28

input:


output:

28
18

result:

points 1.0 L = 18 (test case 1)

Test #6:

score: 15
Accepted
time: 2ms
memory: 4448kb

input:

1
10000 13538 2152
101011011011101111

output:

01110010010011010101
20

input:


output:

20
18

result:

points 1.0 L = 18 (test case 1)

Test #7:

score: 15
Accepted
time: 3ms
memory: 4444kb

input:

1
10000 14224 6947
101011011011111001

output:

01111110010000001100
29

input:


output:

29
18

result:

points 1.0 L = 18 (test case 1)

Test #8:

score: 15
Accepted
time: 6ms
memory: 4424kb

input:

1
10000 12377 8821
100110100011011011

output:

01011111101001111000
31

input:


output:

31
18

result:

points 1.0 L = 18 (test case 1)

Test #9:

score: 15
Accepted
time: 6ms
memory: 4452kb

input:

1
10000 6368 8055
00101010000000110010001

output:

00101000100010100110
240

input:


output:

240
23

result:

points 1.0 L = 23 (test case 1)

Test #10:

score: 15
Accepted
time: 3ms
memory: 4748kb

input:

1
8191 13973 10044
011101111111101110010

output:

01111001111000010010
23

input:


output:

23
21

result:

points 1.0 L = 21 (test case 1)

Test #11:

score: 15
Accepted
time: 5ms
memory: 4712kb

input:

1
9996 11082 3174
101011011011001001110

output:

01001100100001110110
54

input:


output:

54
21

result:

points 1.0 L = 21 (test case 1)

Test #12:

score: 15
Accepted
time: 6ms
memory: 4500kb

input:

1
9996 10015 10295
011101111111110100000

output:

01000010001101011011
70

input:


output:

70
21

result:

points 1.0 L = 21 (test case 1)

Test #13:

score: 15
Accepted
time: 9ms
memory: 4748kb

input:

1
10000 10510 10468
10101101111010110

output:

01000100111100000100
96

input:


output:

96
17

result:

points 1.0 L = 17 (test case 1)

Test #14:

score: 15
Accepted
time: 6ms
memory: 4508kb

input:

1
10000 19991 20005
11000001010000001

output:

11111001011100100101
9999

input:


output:

9999
17

result:

points 1.0 L = 17 (test case 1)

Test #15:

score: 15
Accepted
time: 3ms
memory: 4736kb

input:

1
9997 2964 5900
11111110101110000000111

output:

00010101101111010010
218

input:


output:

218
23

result:

points 1.0 L = 23 (test case 1)

Subtask #2:

score: 85
Accepted

Test #16:

score: 85
Accepted
time: 6ms
memory: 4744kb

input:

15
2 0 1
0
3 2 0
0
4 1 2
0
5 5 0
01
10000 5421 5927
101011011011101110
10000 2685 7116
10011010001111111
10000 440 4972
00111000100000101110
10000 437 10207
00111001010000
10000 8607 4386
10110001011000001
8191 14003 6342
011101111111101110000
9996 8095 6423
101011011011001001011
9996 10090 3334
011...

output:

00000000000000000000
1
00000000000000000000
1
00000000000000000000
2
00000000000000000000
2
00010101111111001111
20
00011111100111000101
24
00001111011011110101
20
01000000111110000100
21
00101110001010111110
1866
01111010010011011001
20
00101000111101101101
50
00111111011011010110
62
01111100110100...

input:


output:

1
1
2
2
20
24
20
21
1866
20
50
62
172
9999
659
21

result:

points 1.0 L = 21 (test case 15)

Test #17:

score: 85
Accepted
time: 7ms
memory: 4516kb

input:

50
2 1 0
0
3 0 1
0
4 0 2
0
5 2 1
0
6 2 1
0
7 9 4
01
8 8 4
0101
9 17 15
0101
10 22 0
00111000111111
11 16 18
01
12 0 18
00111000111111
13 0 16
0001000101110000011111
14 26 19
0111
15 21 24
0101
16 36 21
0000110111000110111111
17 21 14
0111
18 28 15
00000
19 33 19
100110100011000000
20 25 17
0111
21 5...

output:

00000000000000000000
1
00000000000000000000
1
00000000000000000000
1
00000000000000000000
2
00000000000000000000
2
00000000000000000000
1
00000000000000000000
1
00000000000000000010
1
00000000000000000001
4
00000000000000000010
1
00000000000000000001
3
00000000000000000001
3
00000000000000000010
3
0...

input:


output:

1
1
1
2
2
1
1
1
4
1
3
3
3
6
8
3
3
7
5
8
4
2
4
5
4
6
1
4
3
3
2
6
2
3
4
8
6
1
9
11
3
1
9
1
4
7
4
1
5
7
24

result:

points 1.0 L = 24 (test case 50)

Test #18:

score: 85
Accepted
time: 7ms
memory: 4448kb

input:

50
10000 14229 3478
100000101111100000111
10000 12375 4218
00111001001011
10000 1144 12298
101001010010011000010
10000 15754 7760
101011011011111010
10000 46 4759
01100
10000 2609 8366
011001101110010010000
10000 8063 3126
101011011011110101
10000 9805 4159
101011011011110101
10000 3943 2550
0001000...

output:

01111110001100010100
29
01011111010110111011
19
01011110001110101010
26
10011010110001001001
32
00001110000100100001
21
00101011101000000001
23
00101000011110111111
29
00111011111110001111
26
00001001101101111011
21
10010110010101110011
29
10101010000000010010
28
10000011110110011011
29
000101111100...

input:


output:

29
19
26
32
21
23
29
26
21
29
28
29
24
16
25
27
27
22
26
23
29
24
30
28
30
23
21
19
19
35
28
34
23
23
30
23
17
24
34
26
21
32
27
36
22
28
28
28
25
15
24

result:

points 1.0 L = 24 (test case 50)

Test #19:

score: 85
Accepted
time: 7ms
memory: 4400kb

input:

50
10000 12138 4410
100110100011010011
10000 9397 1251
100110100011010001
10000 5750 10642
0001000101110110111
10000 1457 15690
00111001001100
10000 1989 16282
0001000101110111010
10000 5650 4200
100110100011010100
10000 9680 10687
101011011011110111
10000 2900 10237
101011011011110100
10000 5899 66...

output:

01011011111100010001
21
00110111000100001001
23
01000110101100110110
29
10011001010010011000
18
10100101010010010000
29
00010011111100101010
25
01000111010100111101
30
01000001010111101001
25
00011011111011111000
27
01001101111101111111
26
01000011010110011101
27
01000110110010110011
25
101011101001...

input:


output:

21
23
29
18
29
25
30
25
27
26
27
25
38
21
24
35
34
37
22
23
30
27
26
25
27
39
29
25
26
33
18
25
20
30
20
32
28
29
20
20
25
15
35
28
25
20
20
15
28
30
21

result:

points 1.0 L = 21 (test case 50)

Test #20:

score: 85
Accepted
time: 3ms
memory: 4460kb

input:

50
10000 5352 10859
101011011011100111
10000 1879 1012
101011011011101101
10000 13571 4516
00010001100010110
10000 5016 7800
0011110101101000100
10000 16220 13912
101011011100000001
10000 3551 6044
101011011011101111
10000 3612 12744
101011011011110101
10000 2089 10011
110101001100101111
10000 9996 ...

output:

01001001100000011010
14
00000010001110011101
19
01110010110100001111
29
00100110000001110001
25
10100100000100110110
41
00010110110010100101
23
01100101010000101011
25
00111110100001110111
20
01100110010000110101
28
10000111111001000101
21
00110100110011110111
23
01000001011010001101
27
100000100110...

input:


output:

14
19
29
25
41
23
25
20
28
21
23
27
29
27
25
29
18
27
18
27
19
27
20
25
26
18
21
26
23
24
25
16
28
39
22
25
30
23
4
20
29
24
25
19
22
31
30
26
32
27
22

result:

points 1.0 L = 22 (test case 50)

Test #21:

score: 85
Accepted
time: 7ms
memory: 4448kb

input:

50
10000 13783 6607
10110111101011101
10000 13747 12478
0101001110101101000011
10000 12418 4242
100100111100010000010011
10000 13483 17009
11011011101110
10000 13569 1456
110000101011100010
10000 12517 7327
01010100001001
10000 15577 14049
11000101101111100
10000 6428 12289
0100100110
10000 3324 564...

output:

01110110011011100011
5096
01110101110100000010
228
01100000001110010011
1178
10110100010010100100
422
01110010110000110101
1510
01100001110011001100
1743
10010111010100110111
2292
01011110000110110110
1293
00010011111011101011
137
00101010011111010101
244
01010001111111010000
562
1010011100010110110...

input:


output:

5096
228
1178
422
1510
1743
2292
1293
137
244
562
433
800
881
782
360
320
697
116
475
216
107
489
724
424
152
365
192
99
333
304
338
476
382
423
99
104
241
347
276
286
346
508
335
198
276
266
153
124
352
24

result:

points 1.0 L = 24 (test case 50)

Test #22:

score: 85
Accepted
time: 7ms
memory: 4448kb

input:

50
10000 169 12398
011001101110011111110
10000 15973 10683
11010111000010
10000 8283 2521
001110
10000 10489 3610
00010001100110001
10000 14144 14448
101011011100101111
10000 4900 12310
101011011100001001
10000 13880 8792
100110100011101101
10000 2268 5778
101011011011110111
10000 13412 2169
11100
1...

output:

01011111101110000011
132
10011110111101111101
122
00101010110000001100
53
01000100101000101100
57
10000010011000010110
83
01011110100000100110
45
01111000001010000100
50
00010100110011111000
28
01110000001011111011
35
10001010101011011111
38
10101011111010011000
46
01011010000000011011
23
0000010100...

input:


output:

132
122
53
57
83
45
50
28
35
38
46
23
20
36
29
34
39
27
18
30
31
28
34
21
21
26
19
35
31
22
24
33
27
29
27
28
32
37
27
18
25
28
26
23
27
31
31
17
17
27
21

result:

points 1.0 L = 21 (test case 50)

Test #23:

score: 85
Accepted
time: 7ms
memory: 4452kb

input:

50
10000 8598 14565
1111010010001010101111
10000 10255 12365
1001101101
9996 10817 8708
10001010111001110010011
10000 14392 12555
10101111011001010
10000 13230 7333
11000010010111000
9996 8484 5795
10101101111001000
9996 4669 1992
10101101111111100
10000 5120 4056
10101110000011001
9990 15231 9142
1...

output:

10000100010011101110
853
01011111011101101010
1620
01001000111111111000
154
10000001010110001010
849
01101101010000010100
559
00101101000000001110
80
00001101100111001001
131
00010000011000001100
163
10010000100001101101
101
10110001111010101101
91
10100010110010111101
149
01111001110010111001
227
0...

input:


output:

853
1620
154
849
559
80
131
163
101
91
149
227
253
142
194
215
80
167
89
261
185
192
168
87
182
74
98
79
175
64
75
153
34
134
93
155
34
101
187
91
96
105
166
228
143
151
125
115
183
95
23

result:

points 1.0 L = 23 (test case 50)

Test #24:

score: 85
Accepted
time: 7ms
memory: 4452kb

input:

50
10000 9954 14599
10111001101110000
10000 3087 15242
1100011101101010100111
9996 18395 13419
10110010111001110
10000 5316 9335
10101111100001101
10000 10563 9741
10101111101110111
9996 17889 12641
10110000001110011
9996 5106 12996
10101111000000100
10000 11515 1026
10101110100000110
9990 11088 534...

output:

10000100110101110010
6135
10010000101011111100
1520
11010010110101101111
2649
00110110010100011010
920
01000101101010010010
1025
11000111011100001001
1280
01101001010100111100
652
01010010100110010110
397
01001100110000101010
457
01000110001101101010
521
01110011000001000101
379
11101111010101101000...

input:


output:

6135
1520
2649
920
1025
1280
652
397
457
521
379
721
359
543
436
283
248
267
99
312
231
178
186
282
95
303
144
129
335
146
267
216
25
119
184
78
269
128
96
137
164
204
125
78
103
72
140
85
182
159
23

result:

points 1.0 L = 23 (test case 50)

Test #25:

score: 85
Accepted
time: 3ms
memory: 4456kb

input:

50
10000 2871 733
011001101110010001101
10000 14162 1863
101011011011101100
10000 14664 7944
011101111111101111100
10000 10502 2170
100000101111100000111
10000 13040 12007
0001000101110111101
10000 13507 10397
0001101100111011011
10000 10626 7816
011101111111101101101
10000 5339 16236
00010001011101...

output:

00000101001010101111
18
01111100111011010011
18
10000110000101001011
34
01000100110010110100
26
01101010001000001111
36
01110001101111010000
35
01000110100011010010
17
10100100001101011001
26
10101101010000010000
38
01000101111010000011
24
10101010100001000110
36
10011000101111001111
31
011000100000...

input:


output:

18
18
34
26
36
35
17
26
38
24
36
31
28
22
30
30
35
15
25
36
30
13
31
26
30
34
26
27
4
34
13
34
17
28
29
33
16
23
23
29
27
15
29
26
27
27
23
25
23
25
21

result:

points 1.0 L = 21 (test case 50)

Test #26:

score: 85
Accepted
time: 3ms
memory: 4528kb

input:

48
3 1 0
0
7 4 3
0101
15 28 20
011101111111101100000
31 56 47
011101111111101100000
63 74 6
011101001100010111001111
127 256 62
011101111111101100110
255 382 88
011101111111101101000
511 714 42
011101111111101100011
1023 885 1530
011101111111101101100
2047 1624 827
011101111111101101100
4095 4749 11...

output:

00000000000000000000
1
00000000000000000000
2
00000000000000000100
4
00000000000000001101
4
00000000000000001111
5
00000000000010101111
12
00000000000110000000
14
00000000010100110001
5
00000001011110101010
18
00000001101010111101
15
00001110000101110000
22
10001110110011101111
18
000000000000000000...

input:


output:

1
2
4
4
5
12
14
5
18
15
22
18
2
1
5
3
9
7
13
11
13
17
17
18
2
1
3
3
3
9
14
13
16
19
16
22
1
2
4
2
7
2
5
14
13
15
17
21
24

result:

points 1.0 L = 24 (test case 48)

Test #27:

score: 85
Accepted
time: 6ms
memory: 4460kb

input:

48
60 46 15
0001001110010011010111
60 62 5
00100
60 0 58
00111001000010
56 59 72
011101111111101100110
56 18 58
011101100101111111110111
54 61 28
011101111111101100011
60 43 76
011101111111101100110
55 61 18
00010001100000101
60 35 1
0001011111011001000111
52 31 68
101000011100100100111111
56 59 23
...

output:

00000000000000000111
5
00000000000000001010
12
00000000000000001010
5
00000000000000010011
11
00000000000000001011
6
00000000000000001100
7
00000000000000010010
11
00000000000000001011
11
00000000000000000011
6
00000000000000001100
9
00000000000000001011
6
00000000000000101100
2
00000000000000011011...

input:


output:

5
12
5
11
6
7
11
11
6
9
6
2
1
6
8
7
33
50
52
53
55
49
48
68
68
61
62
48
53
59
65
55
32
44
53
48
32
53
37
55
66
48
38
63
60
55
51
65
24

result:

points 1.0 L = 24 (test case 48)

Test #28:

score: 85
Accepted
time: 3ms
memory: 4752kb

input:

48
60 28 0
00001
60 2 60
0001000101110000100010
60 60 25
1110000101000011100111
56 87 102
011101111111101100110
56 105 76
011101111111101101001
54 15 61
1110000010100111010111
60 18 76
0001000101110100100
55 36 66
011001101110010000101
60 70 63
011101111111101101000
52 47 35
101011011011000100000
56...

output:

00000000000000000011
3
00000000000000001010
8
00000000000000001011
9
00000000000000100010
12
00000000000000100001
16
00000000000000001011
7
00000000000000010000
10
00000000000000001100
14
00000000000000010011
13
00000000000000001000
7
00000000000000001101
9
00000000000000010001
8
0000000000000001001...

input:


output:

3
8
9
12
16
7
10
14
13
7
9
8
9
8
7
10
45
67
62
27
51
57
78
60
62
38
78
50
44
29
52
69
46
64
55
59
33
51
20
66
38
68
75
64
53
47
41
67
24

result:

points 1.0 L = 24 (test case 48)

Test #29:

score: 85
Accepted
time: 4ms
memory: 4444kb

input:

50
4 4 0
01
7 4 8
01
10 15 19
0101
13 21 15
0101
16 25 20
0101
19 21 6
0001001000001100101111
22 42 46
0101
25 42 49
0101
28 47 14
1110010011101101000111
31 49 36
011101111111101100000
34 37 39
0101
37 5 36
0001000101110000100001
40 18 50
1101001001001111011111
43 75 8
00000010011111000010000
46 18 ...

output:

00000000000000000000
2
00000000000000000000
1
00000000000000000010
3
00000000000000000010
2
00000000000000000010
1
00000000000000000001
6
00000000000000001001
2
00000000000000001001
3
00000000000000000111
5
00000000000000001000
8
00000000000000000101
4
00000000000000000011
8
00000000000000000111
7
0...

input:


output:

2
1
3
2
1
6
2
3
5
8
4
8
7
8
8
8
4
7
9
8
8
5
6
9
6
5
4
8
10
9
8
9
7
4
9
4
9
6
10
10
8
9
8
8
11
9
10
10
2
6
24

result:

points 1.0 L = 24 (test case 50)

Test #30:

score: 85
Accepted
time: 7ms
memory: 4440kb

input:

50
10000 17094 16166
10111101111110001
10000 16289 16645
10111101110011101
10000 19922 18032
11000000010001001
10000 19705 17504
10111111111001100
10000 16797 19628
10111111100001000
10000 19950 17202
10111111110111110
10000 18784 19697
11000000100000111
10000 18001 18487
10111111100010110
10000 178...

output:

10110110011010110001
8311
10101100101101100101
8232
11110111101011000000
9483
11110010001000100010
9299
11110000011001111110
9103
11111000010110100101
9284
11110001110011111110
9619
11010101001010111001
9120
11000110010001110101
8821
11101110010111011101
9239
11110101010001001111
9811
11110000000011...

input:


output:

8311
8232
9483
9299
9103
9284
9619
9120
8821
9239
9811
8984
8961
8830
9081
8820
8968
8551
8900
8774
9137
9142
9647
9346
9173
9302
9065
8626
9195
9105
9668
8908
8705
9318
9776
9097
8813
8679
9520
9501
9288
8882
9696
8858
8436
9466
9525
9681
8480
8759
17

result:

points 1.0 L = 17 (test case 50)

Test #31:

score: 85
Accepted
time: 7ms
memory: 4400kb

input:

50
10000 19991 0
0000110111000110110110
10000 2 20005
0010000100000000101110
10000 16097 2096
1100011110001001100100
10000 16824 490
1100011110010010101001
10000 16284 2852
1100011110000111011000
10000 16930 609
1100011110010010101001
10000 17350 3262
1100011110001001111001
10000 19289 1841
11000111...

output:

11111000101111111110
4999
11111001000110010010
4999
10100001010101011000
3501
10110000001110101100
4085
10100101010011001101
3357
10110010100101100000
4080
10111011100110011101
3523
11100111101010010100
4363
11101001101010111101
4557
11001001001000010011
4002
11101101000110000000
4121
10101111101011...

input:


output:

4999
4999
3501
4085
3357
4080
3523
4363
4557
4002
4121
3501
3550
3643
3335
4092
3928
3860
4228
3464
3446
3884
3859
3951
4608
3979
3683
4508
4457
4365
4047
4003
3518
4324
4152
4284
4075
4115
4782
3810
1
1
1
1
1
1
1
1
1
1
22

result:

points 1.0 L = 22 (test case 50)

Test #32:

score: 85
Accepted
time: 3ms
memory: 4744kb

input:

50
10000 17000 18454
10100111101110111
10000 16430 15596
11100000111000010
10000 17740 17006
11100010000010111
10000 16039 15928
10100110010001011
10000 16396 15242
10111001100111110
10000 18253 15050
00000010011010
10000 17925 15141
10100110110011011
10000 15003 17821
10011101100111
10000 15245 182...

output:

11010100100000100011
6924
10101000011000000001
6183
11000100011010001100
6782
10100000011101000110
6181
10100111110010111110
6085
11001111101011000111
6513
11001000011010111001
6451
11000101111011001011
6449
11001111000010100111
6450
11000010001111111101
6737
11001001010111100010
6496
10101111000001...

input:


output:

6924
6183
6782
6181
6085
6513
6451
6449
6450
6737
6496
6143
6361
6883
6082
6441
6689
6117
6391
6514
6582
6624
6694
6392
6158
6004
6553
6535
6319
6516
6426
7243
6280
6633
6312
6145
6509
6538
6158
6203
6296
6342
6558
5934
6883
6810
6685
6897
6074
6560
19

result:

points 1.0 L = 19 (test case 50)

Test #33:

score: 85
Accepted
time: 7ms
memory: 4452kb

input:

50
10000 18353 327
0011101001001010101
10000 115 18409
10110100101111101
10000 16457 1813
1100011101111111101110
10000 17210 1219
0001101000101011101101
10000 17754 2601
0001101001110111100111
10000 14856 1522
1100011100101101110010
10000 16909 2145
1111010000001101101100
10000 15085 2942
1100011101...

output:

11010001101001101000
3647
11010010111011011011
3591
10101000101101010101
2870
10111000100011010010
3058
11000100011101111011
2920
10001001100100101011
2623
10110010000001011101
2855
10001101110001101001
2391
11001111011101011101
2999
10010110100011000001
2950
10011111011000011111
2672
11000000001000...

input:


output:

3647
3591
2870
3058
2920
2623
2855
2391
2999
2950
2672
3250
2963
3299
2605
2214
2897
2434
3007
3558
3023
2879
2645
2723
2530
2771
3270
2732
2628
2978
2594
2722
2419
2690
2899
3079
2291
3542
2412
2930
1
3
1
1
1
5
1
1
1
1
23

result:

points 1.0 L = 23 (test case 50)

Test #34:

score: 85
Accepted
time: 4ms
memory: 4712kb

input:

48
100 163 70
1111010001111101100111
100 74 32
101011011011100110
96 114 19
101011011011101010
98 1 87
0010000001100100101011
96 147 71
01101
99 128 60
01011
100 84 37
0001001110010011011001
99 113 58
01011101111000101001001
96 37 41
100
91 4 14
0011100010011111
98 122 13
0000110101111000111010
90 1...

output:

00000000000001000111
15
00000000000000010001
12
00000000000000100101
15
00000000000000010101
10
00000000000000111100
19
00000000000000110001
16
00000000000000010111
8
00000000000000101000
6
00000000000000000101
2
00000000000000000001
3
00000000000000100100
14
00000000000000101100
1
00000000000000110...

input:


output:

15
12
15
10
19
16
8
6
2
3
14
1
12
10
9
7
2930
2639
1158
216
614
1622
951
445
608
326
821
767
422
115
6
103
2473
1369
1460
804
1359
572
469
269
370
240
458
400
40
1019
574
309
23

result:

points 1.0 L = 23 (test case 48)

Test #35:

score: 85
Accepted
time: 7ms
memory: 4516kb

input:

48
10000 3938 18526
010110100011011111
10000 4524 14294
1100101101101111101100
10000 13906 16962
011100000011000100
10000 6036 18930
1100101101101010000000
10000 3272 10888
1100011101110000101000
10000 16063 18122
011110001101011011110
10000 16052 6990
1100101101100110001100
10000 11381 13369
110001...

output:

11010101111001001011
4501
01111111011101000110
2379
10110011011010001011
7003
11011111011001110011
2016
01001001110110010110
1904
11001100110101100100
7044
10100000100101000010
1773
01101111011010011011
497
10100100001011000111
4349
10101100010111000110
6724
01010100000100110000
1736
000101101101110...

input:


output:

4501
2379
7003
2016
1904
7044
1773
497
4349
6724
1736
1956
5687
5335
3231
446
904
3051
1019
423
613
2333
42
227
3048
3048
2274
42
26
51
21
2947
141
150
43
158
40
40
154
52
49
44
36
39
58
173
44
164
23

result:

points 1.0 L = 23 (test case 48)

Test #36:

score: 85
Accepted
time: 7ms
memory: 4468kb

input:

50
9828 2177 4034
0011111110001
9828 5155 5246
0000111110011011101111
9828 4628 4931
0100001011100000101111
9828 9339 9581
0010100100111110001111
9828 2517 2805
0100001011100000101111
9828 10818 10930
0010111110100110110111
9828 8563 8898
0100100101001001010111
9828 10651 10744
000101100000010001011...

output:

00001010001100101011
199
00010001001101011101
7
00001111001111111010
10
00111001010110111001
6
00000100111100110111
12
01001010100011010010
7
00110001011100101101
9
01001000000101111000
7
00110100100110110010
9
00000000000011101110
12
00101110101100010000
6
00100110100111101001
6
0000000000011101110...

input:


output:

199
7
10
6
12
7
9
7
9
12
6
6
14
423
7
4
5
6
10
7
5
6
6
15
9
7
514
6
4
10
8
13
6
6
7
10
10
7
12
325
5
8
6
6
4
7
7
7
5
12
22

result:

points 1.0 L = 22 (test case 50)

Test #37:

score: 85
Accepted
time: 7ms
memory: 4452kb

input:

50
9828 1110 1502
1011110010100100100111
9828 7755 8198
1100100101110101110111
9828 3992 4952
10101110010010110
9828 1257 1347
0111110010001110010111
9828 8858 9149
1010100101101010101111
9828 4679 4877
1001011000110000110111
9828 987 1249
1010100101101010101111
9828 120 276
1001110010011001011111
9...

output:

00000001011011100001
6
00101001111110110110
5
00001111010100101110
285
00000001001010001001
9
00110100010010010011
13
00001110111010000100
5
00000000111111101011
10
00000000000011000110
9
01000101010011010010
7
00001111100000101101
5
00000100011011010001
6
01000110011010010010
3
00001111100110001100...

input:


output:

6
5
285
9
13
5
10
9
7
5
6
3
10
12
8
588
3
9
12
13
5
9
10
7
7
10
6
6
260
8
10
9
3
9
10
6
2
2
9
3
10
174
8
8
14
7
12
8
4
5
23

result:

points 1.0 L = 23 (test case 50)

Test #38:

score: 85
Accepted
time: 7ms
memory: 4448kb

input:

50
9828 5044 5253
1111011001010010001111
9828 3602 3894
00001011001011101010111
9828 2518 2680
1110001100011000010111
9828 4421 4653
00000001100100011011111
9828 1575 4953
0011111111011
9828 7738 7821
0000111110011011101111
9828 6847 7177
0110100101010100011111
9828 2505 2718
0010100100111110001111
...

output:

00010001010011001100
4
00001001100001111110
4
00000100100001010011
10
00001101100100101001
11
00001111010010000001
213
00100110001101100001
9
00100000001011101001
11
00000100101010010101
10
00100100111111010000
12
00100101110011001011
10
00111110011111001000
14
00001111100000101101
3
000000000110001...

input:


output:

4
4
10
11
213
9
11
10
12
10
14
3
10
12
13
1
13
4
5
4
7
7
8
8
11
11
2
1
15
11
295
4
3
6
10
14
10
10
4
8
9
11
9
205
4
9
6
10
10
7
23

result:

points 1.0 L = 23 (test case 50)

Test #39:

score: 85
Accepted
time: 7ms
memory: 4744kb

input:

50
9828 5140 5256
0001011000000100010111
9828 2433 2551
0001011000000100010111
9828 5592 5901
00111110011100111010111
9828 7214 7537
0110100101010100011111
9828 5922 6263
0110111110111101000111
9828 325 601
0110001011101011110111
9828 8656 11022
0100110010110
9828 9753 9856
0000111110011011101111
98...

output:

00010001010011010011
4
00000100000110111010
6
00010101110010001110
8
00100011100001100010
6
00011000100011000111
8
00000000001110011110
12
01001011110110101000
620
00111100110000011000
4
00100110001101100001
5
00000110101001011111
12
00111011011000011100
12
01000110011010001101
10
000001100110110011...

input:


output:

4
6
8
6
8
12
620
4
5
12
12
10
8
5
10
8
6
7
8
118
3
13
12
9
10
5
7
7
7
8
12
13
61
6
7
8
9
10
9
8
5
5
7
8
8
163
7
8
6
10
23

result:

points 1.0 L = 23 (test case 50)

Test #40:

score: 85
Accepted
time: 5ms
memory: 4460kb

input:

50
9828 7409 7691
01010001101011011000111
9828 6312 6522
01001011010001001110111
9828 5017 5169
1110001100011000010111
9828 5491 5721
1111011001010010001111
9828 4496 4728
1111011001010010001111
9828 2907 3194
00001011001011101010111
9828 6205 6447
1111110010111010110111
9828 10842 10925
11100011000...

output:

00100100111111010000
6
00011010100011111011
10
00010000110000001111
3
00010100011101110100
11
00001101111110111010
8
00000110011011001001
5
00011001111111101001
10
01001010100011010100
9
00010111101000100111
88
00000000101000111011
6
00000101111110111100
6
00101101111100001011
6
00000111110101101110...

input:


output:

6
10
3
11
8
5
10
9
88
6
6
6
11
2
9
7
13
8
6
6
13
286
11
3
10
4
9
9
11
12
13
10
3
6
278
5
4
9
12
14
8
9
2
7
14
13
13
555
9
4
23

result:

points 1.0 L = 23 (test case 50)

Test #41:

score: 85
Accepted
time: 7ms
memory: 4752kb

input:

50
9828 1503 1794
01011011010010100111111
9828 8886 9170
01011000000101100010111
9828 7430 7763
01011011010010100111111
9828 1325 1512
01010100111000011101111
9828 10073 10398
00101011001110011100111
9828 2025 2211
00010100110010111001111
9828 4217 4462
00100001100111001101111
9828 8246 8513
0010101...

output:

00000010000010101011
8
00110100100110110010
3
00100101101010011001
5
00000001011101011100
4
01000011011110010100
13
00000011000100000011
13
00001100011101001110
11
00101101010101111101
6
00000100011011001010
7
00010010110011010011
7
00000011011000010000
19
00000000101000111011
8
00000010000000101110...

input:


output:

8
3
5
4
13
13
11
6
7
7
19
8
5
12
12
11
3
5
6
4
10
9
6
496
4
8
4
10
11
6
7
8
9
10
15
9
267
13
14
6
9
6
6
4
8
2
7
10
6
414
23

result:

points 1.0 L = 23 (test case 50)

Test #42:

score: 85
Accepted
time: 7ms
memory: 4532kb

input:

50
9828 1295 1434
10001000001001101101111
9828 2303 2460
10010001110000111100111
9828 3881 4120
10010100111110000001111
9828 4238 4530
10011110100101010000111
9828 8328 8720
10100100111111011010111
9828 5019 5244
10011000001011000110111
9828 7787 7874
10001011010110110010111
9828 9903 10112
10010001...

output:

00000001010011100001
8
00000011110011001100
7
00001010101001111010
4
00001100110110010100
6
00101111011100101011
17
00010001001101010011
11
00100110110000100111
7
00111111111001001110
8
00011101001111101001
13
00110111100001111010
2
00100001101101000001
12
00101111110000010000
7
00100100110101111100...

input:


output:

8
7
4
6
17
11
7
8
13
2
12
7
458
11
10
9
13
6
10
7
9
6
9
8
9
529
7
8
9
6
8
7
7
7
6
12
12
7
124
4
6
7
4
2
7
4
7
6
15
9
23

result:

points 1.0 L = 23 (test case 50)

Test #43:

score: 85
Accepted
time: 7ms
memory: 4736kb

input:

50
9828 5420 5672
11001011011100010110111
9828 413 515
1001111100010001011
9828 217 351
01011110011111101100111
9828 7264 7477
01101110100001000101111
9828 4898 5147
01101011010100000000111
9828 6946 7264
01111000001000010100111
9828 9981 10321
10000001101111100011111
9828 1122 1338
0110111010000100...

output:

00010100001010101010
4
00000000001010110111
37
00000000000101010100
6
00100011000000000011
6
00010000100100100101
8
00100000111100000101
12
01000010100100011001
13
00000001001000100000
9
00001010010111101100
5
00000110111100001010
10
01000110001110011001
8
01000101101010111000
9
00101010100011110000...

input:


output:

4
37
6
6
8
12
13
9
5
10
8
9
9
6
168
11
7
6
4
2
6
9
3
10
9
6
10
232
5
6
4
10
13
14
11
8
8
7
8
10
324
8
7
3
11
8
12
9
6
4
24

result:

points 1.0 L = 24 (test case 50)

Test #44:

score: 85
Accepted
time: 7ms
memory: 4400kb

input:

50
9828 10128 10460
000010101001001001001111
9828 9491 9821
000011011100011010011111
9828 1874 2263
000100101001010100010111
9828 2572 5417
10011100101010100111
9828 10376 10521
11111110101101100110111
9828 4672 4860
000000101000111110000111
9828 4736 4997
000001011100001111010111
9828 16 83
0001101...

output:

01000100011000100101
3
00111100001111001000
6
00000011001101110110
18
00010010010001111010
260
01000101000111101101
7
00001110110100100111
9
00001111100110001100
12
00000000000000010000
12
00011110000101011101
8
00010110001100101001
16
00110011110011111000
7
00011000111111011100
5
000001111000100010...

input:


output:

3
6
18
260
7
9
12
12
8
16
7
5
7
8
11
9
165
6
9
5
5
6
2
10
9
4
11
6
8
403
5
10
7
13
8
8
6
10
15
8
5
8
366
8
7
10
5
12
10
6
24

result:

points 1.0 L = 24 (test case 50)

Test #45:

score: 85
Accepted
time: 7ms
memory: 4460kb

input:

50
9828 5025 5179
000101110110001110001111
9828 1745 1970
000111000011001000000111
9828 3222 3521
001000101001101010100111
9828 9266 9437
000110001111110110110111
9828 9899 10200
000111110110011001010111
9828 8935 5893
1100101000010011100000
9828 2240 2371
001001110110100100011111
9828 8488 8642
001...

output:

00010000110000001111
15
00000010011100001010
10
00000111110001110000
8
00110111101100101000
9
01000000111101001111
9
00110001110111100101
92
00000011100010111101
5
00101110101100011011
7
00000010111111000101
6
01000000110001110111
8
00000000101110100010
6
00000100000000111001
9
00110010100010111100
...

input:


output:

15
10
8
9
9
92
5
7
6
8
6
9
4
9
11
9
12
9
64
8
5
3
9
14
8
11
7
10
9
10
11
379
10
11
7
5
5
7
5
7
14
10
8
9
239
8
7
11
10
16
24

result:

points 1.0 L = 24 (test case 50)

Test #46:

score: 85
Accepted
time: 4ms
memory: 4528kb

input:

50
9828 5453 5825
010001110111010000111111
9828 8020 8144
001111011101011101001111
9828 9704 9925
010000010000101110011111
9828 2149 2401
010001000011111111101111
9828 159 470
010010101010100010001111
9828 2162 2499
010010010000111001100111
9828 9762 10128
010010101010100010001111
9828 1141 4942
001...

output:

00010101010001010101
3
00101001011010101011
10
00111101011100011111
8
00000011101000001011
12
00000000001000111100
13
00000011111011010101
7
01000000000100010111
7
00001111010001100010
124
00110001010010111110
8
00001111110111001000
4
00101101000010111110
2
00001010001010000010
11
001110001011000000...

input:


output:

3
10
8
12
13
7
7
124
8
4
2
11
3
7
9
8
8
6
13
11
283
8
9
11
11
8
8
10
3
12
14
8
11
404
2
6
6
8
7
9
13
9
4
5
7
6
316
9
6
6
24

result:

points 1.0 L = 24 (test case 50)

Test #47:

score: 85
Accepted
time: 7ms
memory: 4424kb

input:

50
9828 9364 9677
011011011110011111111111
9828 1644 2033
011011000100110111010111
9828 3651 4003
011011011110011111111111
9828 2934 3016
010111110111110010010111
9828 1766 1912
011000101011000011100111
9828 3058 3242
011000010001011010111111
9828 2174 2480
011010010001100110000111
9828 7496 7863
01...

output:

00111010100010001010
3
00000010100111001110
5
00001010000000110111
9
00000101101110000101
9
00000010010011100010
6
00000110100110000110
6
00000011111000100100
4
00100110100111100000
14
00111111000000110000
14
00000010101100001100
136
00110001100110111001
3
00111010111000000010
7
00001011100111001101...

input:


output:

3
5
9
9
6
6
4
14
14
136
3
7
7
4
8
4
12
8
5
16
7
10
55
9
5
8
7
9
11
5
13
14
9
7
9
35
13
3
4
11
11
13
5
6
11
12
10
12
173
7
24

result:

points 1.0 L = 24 (test case 50)

Test #48:

score: 85
Accepted
time: 3ms
memory: 4740kb

input:

50
9828 4602 4725
100101011111010111100111
9828 7265 7485
100111011111100010101111
9828 8941 9232
101000101100011100100111
9828 5210 5465
100111111001001011010111
9828 1947 2152
100101111001000000001111
9828 6768 6967
100101011111010111100111
9828 9295 9511
100110101100010001011111
9828 3964 4250
10...

output:

00001101111111000001
10
00100011000000000011
7
00110101001111111100
11
00010010101101001001
6
00000010111010010000
9
00011110010101001100
10
00111000100001100011
11
00001011010100000011
9
01000100011000101110
10
01000000000100100100
7
00000001010110101100
11
00110111101100100101
15
00000011101101100...

input:


output:

10
7
11
6
9
10
11
9
10
7
11
15
5
3
9
7
10
10
10
4
7
7
5
7
169
5
6
5
10
14
10
7
5
15
3
9
13
566
6
14
7
10
4
9
11
7
8
5
15
9
24

result:

points 1.0 L = 24 (test case 50)

Test #49:

score: 85
Accepted
time: 3ms
memory: 4456kb

input:

50
9828 10660 10314
011000000011101110
9828 6181 6388
100001111000101001111111
9828 7691 7845
100001111000101001111111
9828 1131 1335
101111100000001111001111
9828 3104 3437
110000010011100000011111
9828 7068 7292
101111111001110111110111
9828 10454 10648
101111000110100110100111
9828 4727 5054
1100...

output:

01000110111101110101
662
00011001100010111101
8
00100110011110111101
4
00000001001000100000
11
00000111011010010100
5
00100001001100011100
14
01000110110010000110
9
00010000000010001110
8
00000110100010100001
7
01000001011111101001
1
00101000110110001111
13
00111010000001110000
14
001110111000111001...

input:


output:

662
8
4
11
5
14
9
8
7
1
13
14
11
196
11
6
7
10
3
5
7
9
11
10
4
5
344
7
12
7
9
6
13
8
9
9
9
1
9
11
7
9
8
15
5
9
9
7
1
7
24

result:

points 1.0 L = 24 (test case 50)

Test #50:

score: 85
Accepted
time: 5ms
memory: 4744kb

input:

50
9828 3728 4037
101101000110011011011111
9828 4345 4643
101100101100110010110111
9828 8044 4535
011100111000001000
9828 8523 8835
101101000110011011011111
9828 7522 7701
101010010010111111000111
9828 150 362
101010101100100111101111
9828 4522 4747
101011000110010000010111
9828 7657 7772
1010010111...

output:

00001010001110011010
11
00001101011111011000
8
00101000010111100100
403
00110000110101000100
3
00100101000111111110
6
00000000000101001111
13
00001110001001100001
5
00100101110011010100
9
00011010000110111000
4
00001101010101000100
9
00011000111111011100
6
00001010010111100011
6
00100001110101010101...

input:


output:

11
8
403
3
6
13
5
9
4
9
6
6
12
8
4
221
3
9
10
9
9
8
9
8
13
4
9
7
198
13
9
5
13
7
7
11
10
11
7
8
11
194
7
5
9
8
11
5
7
9
24

result:

points 1.0 L = 24 (test case 50)

Test #51:

score: 85
Accepted
time: 7ms
memory: 4424kb

input:

50
9828 3837 4028
100010101011111011001111
9828 8166 8480
100100010010011101101111
9828 9749 10114
100101000101101110111111
9828 2170 2497
100100101100000110010111
9828 10640 268
010111111110110100
9828 8322 8533
100011011111001100011111
9828 6894 7075
100001000101011000101111
9828 1191 1431
1000101...

output:

00001010001010000010
8
00101100111001011010
12
00111111111001000011
7
00000011111011010110
8
01000110100110101111
343
00101101011111100011
8
00011111010100000001
8
00000001010011011010
5
00111010101100111110
14
00000000000110100011
1
01001000110101111010
13
00100101111100000000
10
000011010101010010...

input:


output:

8
12
7
8
343
8
8
5
14
1
13
10
7
6
6
8
8
123
6
5
5
3
3
5
5
8
8
3
13
5
395
12
5
5
10
11
10
5
8
8
8
9
6
172
7
9
9
8
10
9
24

result:

points 1.0 L = 24 (test case 50)

Test #52:

score: 85
Accepted
time: 7ms
memory: 4488kb

input:

50
9828 10227 10612
110100101101011111010111
9828 705 914
110001000110110001101111
9828 1771 2022
110010101101010100001111
9828 9170 9457
110011100000100101011111
9828 2529 2860
110100101101011111010111
9828 1402 1530
110001100000011010010111
9828 8344 10124
111010000101101100000
9828 9149 9275
1101...

output:

01000110011010000111
3
00000000100010010011
7
00000010100101000110
4
00110111110111000101
9
00000101001001100010
4
00000001011111001111
6
01000000000010110010
579
00110101101111001010
9
00001111011011001001
5
00000111011010100111
6
00001110100100010000
9
00000000010111101011
12
00110011111101111000
...

input:


output:

3
7
4
9
4
6
579
9
5
6
9
12
3
7
7
10
3
9
14
279
10
5
9
9
12
1
4
4
11
10
6
5
462
9
10
10
7
10
10
10
8
13
4
7
7
344
8
5
9
4
24

result:

points 1.0 L = 24 (test case 50)

Test #53:

score: 85
Accepted
time: 2ms
memory: 4464kb

input:

8
9828 4968 5199
111011111010111010100111
9828 5175 5342
111010010100011000000111
9828 4964 5154
111010101110000000101111
9828 3126 3325
111010101110000000101111
9828 9998 10223
111001111010101111011111
9828 6916 7184
111100010100100011001111
9828 8604 8891
111100101110001011110111
9828 9649 9864
11...

output:

00010000111011110000
12
00010001110110110100
9
00010000101010011010
3
00000110111100001010
9
01000001010100001001
6
00100000010011101111
6
00110001011100110000
3
00111100110000010001
9

input:


output:

12
9
3
9
6
6
3
9
24

result:

points 1.0 L = 24 (test case 8)

Test #54:

score: 85
Accepted
time: 7ms
memory: 4444kb

input:

50
10000 19974 20003
10111010101111100
10000 19977 20003
10111010101111100
10000 19968 19999
10111010101111100
10000 19985 20005
10111010101111100
10000 19971 20002
10111010101111100
10000 15635 19999
10111001000011001
10000 19971 17233
10111010101101011
10000 19985 10681
10111001000001111
10000 150...

output:

11111001011100100100
6663
11111001011100100100
6665
11111001011100100100
6659
11111001011100100101
6663
11111001011100100100
6661
11111001010111101110
5795
11111000101100111001
6646
11111000111011111000
5786
11111001000000110011
6355
11111001011100010010
6106
11111001000000000001
5831
11111001000110...

input:


output:

6663
6665
6659
6663
6661
5795
6646
5786
6355
6106
5831
6753
7414
6634
7070
5875
6062
6746
6382
7441
7068
5700
5793
6383
6595
5762
6919
6687
6492
7106
6962
6282
6787
6284
5916
7248
7048
5893
6113
7323
5992
6503
7237
7392
6388
5715
7597
7187
5710
5730
17

result:

points 1.0 L = 17 (test case 50)

Extra Test:

score: 0
Extra Test Passed