QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#296122#4834. TrijectionzhouhuanyiAC ✓15ms4348kbC++146.6kb2024-01-02 10:16:442024-01-02 10:16:44

Judging History

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

  • [2024-01-02 10:16:44]
  • 评测
  • 测评结果:AC
  • 用时:15ms
  • 内存:4348kb
  • [2024-01-02 10:16:44]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 37
#define M 74
using namespace std;
long long read()
{
	char c=0;
	long long sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
int n,t,leng,lengs,p[N+1],ls[M+1],rs[M+1],s[N+1],num[N+1][N+1],sz[N+1],tong[N+1],tong2[N+1],length,length2,a[N+1],b[N+1],c[N+1];
bool used[N+1],vis[N+1][N+1];
long long dp[N+1][N+1][N+1],DP[N+1][N+1],DSP[N+1][N+1],delta[N+1];
struct poly
{
	int h,w;
	char c[N+1][N+1];
};
poly zero;
struct perm
{
	int p[N+1];
};
struct triang
{
	int a[N+1],b[N+1],c[N+1];
};
poly get_read()
{
	poly x;
	x.h=read(),x.w=read();
	for (int i=1;i<=x.h;++i)
		for (int j=1;j<=x.w;++j)
			cin>>x.c[i][j];
	return x;
}
void get_write(poly x)
{
	puts("poly");
	printf("%d %d\n",x.h,x.w);
	for (int i=1;i<=x.h;++i)
	{
		for (int j=1;j<=x.w;++j) printf("%c",x.c[i][j]);
		puts("");
	}
	return;
}
long long get_rk(poly x)
{
	int sx=x.h,sy=0,res=0,res2=0;
	long long ans=1;
	length=length2=0;
	while (sx!=0||sy!=x.w)
	{
		if (sx!=0&&x.c[sx][sy+1]=='#') tong[++length]=0,sx--;
		else tong[++length]=1,sy++;
	}
	sx=x.h,sy=0;
	while (sx!=0||sy!=x.w)
	{
		if (sy==x.w||x.c[sx][sy+1]=='.') tong2[++length2]=0,sx--;
		else tong2[++length2]=1,sy++;
	}
	for (int i=1;i<=n+1;++i)
	{
		for (int j=0;j<(tong[i]<<1)+tong2[i];++j) ans+=dp[i][res+(j>>1)][res2+(j&1)];
		res+=tong[i],res2+=tong2[i];
	}
	return ans;
}
poly get_data(long long x)
{
	poly d=zero;
	int sx,sy,res=0,res2=0,l,r,ps=0;
	for (int i=1;i<=n+1;++i)
		for (int j=0;j<4;++j)
		{
			if (x<=dp[i][res+(j>>1)][res2+(j&1)])
			{
				tong[i]=j>>1,tong2[i]=j&1,res+=(j>>1),res2+=(j&1);
				break;
			}
			else x-=dp[i][res+(j>>1)][res2+(j&1)];
		}
	for (int i=1;i<=n+1;++i) d.h+=(!tong[i]),d.w+=tong[i];
	for (int i=1;i<=d.h;++i)
		for (int j=1;j<=d.w;++j)
			d.c[i][j]='.';
	sx=d.h,sy=0;
	while (sx!=0||sy!=d.w)
	{
		++ps;
		if (!tong[ps]) d.c[sx][sy+1]='#',sx--;
		else sy++;
	}
	sx=d.h,sy=ps=0;
	while (sx!=0||sy!=d.w)
	{
		++ps;
		if (!tong2[ps]) d.c[sx][sy]='#',sx--;
		else sy++;
	}
	for (int i=1;i<=d.h;++i)
	{
		l=d.w,r=0;
		for (int j=1;j<=d.w;++j)
			if (d.c[i][j]=='#')
				l=min(l,j),r=max(r,j);
		for (int j=l;j<=r;++j) d.c[i][j]='#';
	}
	return d;
}
perm get_read2()
{
	perm x;
	for (int i=1;i<=n;++i) x.p[i]=read();
	return x;
}
void get_write2(perm x)
{
	puts("perm");
	for (int i=1;i<=n;++i) printf("%d ",x.p[i]);
	puts("");
	return;
}
long long get_rk2(perm x)
{
	int maxn=0,d=0,ds;
	long long ans=1;
	for (int i=1;i<=n;++i) used[i]=0;
	for (int i=1;i<=n;++i)
	{
		for (int j=1;j<=n;++j) s[j]=s[j-1]+(!used[j]);
		for (int j=1;j<x.p[i];++j)
			if (!used[j])
			{
				if (maxn>j) ds=max(d,j);
				else ds=d;
			    if (!(s[ds]-(ds>=j))) ans+=DSP[n-i][s[max(maxn,j)]];
			}
		used[x.p[i]]=1;
		if (maxn>x.p[i]) d=max(d,x.p[i]);
		maxn=max(maxn,x.p[i]);
	}
	return ans;
}
perm get_data2(long long x)
{
	perm y;
	int maxn=0,d=0,ds;
    for (int i=1;i<=n;++i) used[i]=0;
	for (int i=1;i<=n;++i)
	{
		for (int j=1;j<=n;++j) s[j]=s[j-1]+(!used[j]);
		for (int j=1;j<=n;++j)
			if (!used[j])
			{
				if (maxn>j) ds=max(d,j);
				else ds=d;
				if (!(s[ds]-(ds>=j)))
				{
					if (x<=DSP[n-i][s[max(maxn,j)]])
					{
						y.p[i]=j;
						break;
					}
					else x-=DSP[n-i][s[max(maxn,j)]];
				}
			}
		used[y.p[i]]=1;
		if (maxn>y.p[i]) d=max(d,y.p[i]);
		maxn=max(maxn,y.p[i]);
	}
	return y;
}
triang get_read3()
{
	triang x;
	for (int i=1;i<=n;++i) x.a[i]=read(),x.b[i]=read(),x.c[i]=read();
	return x;
}
void get_write3(triang x)
{
	puts("triang");
	for (int i=1;i<=n;++i) printf("%d %d %d\n",x.a[i],x.b[i],x.c[i]);
	return;
}
void dfs(int x)
{
	if (ls[x]||rs[x]) dfs(ls[x]),dfs(rs[x]),sz[x]=sz[ls[x]]+sz[rs[x]];
	else sz[x]=1;
	return;
}
long long calc(int x)
{
	if (!x) return 0;
	long long res=0;
	for (int i=1;i<sz[ls[x]];++i) res+=delta[i]*delta[sz[x]-i];
	return res+calc(ls[x])*delta[sz[rs[x]]]+calc(rs[x]);
}
long long get_rk3(triang x)
{
	leng=0;
	for (int i=1;i<=n+2;++i)
		for (int j=i+1;j<=n+2;++j)
			vis[i][j]=num[i][j]=0;
	for (int i=1;i<=n;++i) vis[x.a[i]][x.b[i]]=vis[x.b[i]][x.c[i]]=vis[x.a[i]][x.c[i]]=1;
	for (int i=n+2;i>=1;--i)
		for (int j=i+1;j<=n+2;++j)
			if (vis[i][j])
			{
				num[i][j]=++leng,ls[leng]=rs[leng]=0;
				for (int k=i+1;k<=j-1;++k)
					if (vis[i][k]&&vis[k][j])
						ls[num[i][j]]=num[i][k],rs[num[i][j]]=num[k][j];
			}
	dfs(num[1][n+2]);
	return calc(num[1][n+2])+1;
}
int build(int x,long long d)
{
	int nw=++leng;
	ls[nw]=rs[nw]=0;
	if (x==1) return nw;
	for (int i=1;i<=x-1;++i)
	{
		if (d<delta[i]*delta[x-i])
		{
		    ls[nw]=build(i,d/delta[x-i]),rs[nw]=build(x-i,d%delta[x-i]);
			return nw;
		}
		else d-=delta[i]*delta[x-i];
	}
}
void dfs2(int x,int l,int r)
{
	vis[l][r]=1;
	if (l+1==r) return;
	dfs2(ls[x],l,l+sz[ls[x]]),dfs2(rs[x],l+sz[ls[x]],r);
	return;
}
bool cmp(int x,int y)
{
	if (a[x]!=a[y]) return a[x]<a[y];
	else if (b[x]!=b[y]) return b[x]<b[y];
	else return c[x]<c[y];
}
triang get_data3(long long x)
{
	triang d;
	for (int i=1;i<=n+2;++i)
		for (int j=i+1;j<=n+2;++j)
			vis[i][j]=0;
	leng=lengs=0;
	int nw=build(n+1,x-1);
	dfs(nw),dfs2(nw,1,n+2);
	for (int i=1;i<=n+2;++i)
		for (int j=i+1;j<=n+2;++j)
			if (vis[i][j])
				for (int k=i+1;k<=j-1;++k)
					if (vis[i][k]&&vis[k][j])
						++lengs,p[lengs]=lengs,a[lengs]=i,b[lengs]=k,c[lengs]=j;
	sort(p+1,p+lengs+1,cmp);
	for (int i=1;i<=lengs;++i) d.a[i]=a[p[i]],d.b[i]=b[p[i]],d.c[i]=c[p[i]];
	return d;
}
int main()
{
	string s;
	long long x;
	n=read(),t=read();
	for (int i=0;i<=n+1;++i) dp[n+1][i][i]=1;
	for (int i=n+1;i>=1;--i)
		for (int j=0;j<=i-1;++j)
			for (int k=j+(i!=1);k<=i-1;++k)
				dp[i-1][j][k]=dp[i][j][k]+dp[i][j+1][k]+dp[i][j][k+1]+dp[i][j+1][k+1];
    DP[0][1]=1;
	for (int i=1;i<=n;++i)
		for (int j=1;j<=i;++j)
			for (int k=2;k<=j+1;++k)
				DP[i][k]+=DP[i-1][j];
	for (int i=0;i<=n;++i)
		for (int j=i+1;j>=0;--j)
			DSP[i][j]=DSP[i][j+1]+DP[i][j];
	delta[1]=1;
	for (int i=2;i<=n+1;++i)
		for (int j=1;j<=i-1;++j)
			delta[i]+=delta[j]*delta[i-j];
	printf("%d %d\n",n,t);
	while (t--)
	{
		cin>>s;
		if (s=="poly")
		{
			x=get_rk(get_read());
			if (x&1) get_write2(get_data2(x));
			else get_write3(get_data3(x-1));
		}
		else if (s=="perm")
		{
			x=get_rk2(get_read2());
			if (x&1) get_write(get_data(x));
			else get_write3(get_data3(x));
		}
		else
		{
			x=get_rk3(get_read3());
			if (x&1) get_write(get_data(x+1));
			else get_write2(get_data2(x));
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 4
poly
4 2
.#
##
##
#.
perm
4 1 5 2 3
triang
1 2 4
1 4 5
1 5 7
2 3 4
5 6 7
perm
2 1 3 5 4

output:

5 4
perm
1 3 2 5 4 
triang
1 2 3
1 3 5
1 5 6
1 6 7
3 4 5
poly
2 4
####
####
triang
1 2 3
1 3 7
3 4 7
4 5 6
4 6 7

input:

5 4
perm
1 3 2 5 4
triang
1 2 3
1 3 5
1 5 6
1 6 7
3 4 5
poly
2 4
####
####
triang
1 2 3
1 3 7
3 4 7
4 5 6
4 6 7

output:

5 4
poly
4 2
.#
##
##
#.
perm
4 1 5 2 3 
triang
1 2 4
1 4 5
1 5 7
2 3 4
5 6 7
perm
2 1 3 5 4 

result:

ok good communication process (4 test cases)

Test #2:

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

input:

2 6
poly
2 1
#
#
poly
1 2
##
perm
2 1
perm
1 2
triang
1 2 3
1 3 4
triang
1 2 4
2 3 4

output:

2 6
perm
1 2 
triang
1 2 4
2 3 4
triang
1 2 3
1 3 4
poly
2 1
#
#
perm
2 1 
poly
1 2
##

input:

2 6
perm
1 2
triang
1 2 4
2 3 4
triang
1 2 3
1 3 4
poly
2 1
#
#
perm
2 1
poly
1 2
##

output:

2 6
poly
2 1
#
#
poly
1 2
##
perm
2 1 
perm
1 2 
triang
1 2 3
1 3 4
triang
1 2 4
2 3 4

result:

ok good communication process (6 test cases)

Test #3:

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

input:

4 42
poly
3 2
.#
.#
##
poly
3 2
.#
##
#.
poly
3 2
##
#.
#.
poly
2 3
###
#..
poly
2 3
###
##.
poly
2 3
.##
###
poly
4 1
#
#
#
#
poly
3 2
##
##
#.
poly
1 4
####
poly
3 2
##
##
##
poly
3 2
.#
##
##
poly
2 3
.##
##.
poly
2 3
..#
###
poly
2 3
###
###
perm
1 4 2 3
perm
2 3 4 1
perm
2 4 1 3
perm
2 1 3 4
pe...

output:

4 42
triang
1 2 3
1 3 4
1 4 6
4 5 6
triang
1 2 6
2 3 4
2 4 6
4 5 6
triang
1 2 6
2 3 6
3 4 6
4 5 6
perm
1 4 2 3 
triang
1 2 3
1 3 6
3 4 5
3 5 6
triang
1 2 5
1 5 6
2 3 4
2 4 5
perm
1 2 3 4 
perm
1 3 2 4 
triang
1 2 4
1 4 5
1 5 6
2 3 4
triang
1 2 6
2 3 4
2 4 5
2 5 6
perm
2 1 4 3 
perm
3 1 2 4 
perm
3 4...

input:

4 42
triang
1 2 3
1 3 4
1 4 6
4 5 6
triang
1 2 6
2 3 4
2 4 6
4 5 6
triang
1 2 6
2 3 6
3 4 6
4 5 6
perm
1 4 2 3
triang
1 2 3
1 3 6
3 4 5
3 5 6
triang
1 2 5
1 5 6
2 3 4
2 4 5
perm
1 2 3 4
perm
1 3 2 4
triang
1 2 4
1 4 5
1 5 6
2 3 4
triang
1 2 6
2 3 4
2 4 5
2 5 6
perm
2 1 4 3
perm
3 1 2 4
perm
3 4 1 2
...

output:

4 42
poly
3 2
.#
.#
##
poly
3 2
.#
##
#.
poly
3 2
##
#.
#.
poly
2 3
###
#..
poly
2 3
###
##.
poly
2 3
.##
###
poly
4 1
#
#
#
#
poly
3 2
##
##
#.
poly
1 4
####
poly
3 2
##
##
##
poly
3 2
.#
##
##
poly
2 3
.##
##.
poly
2 3
..#
###
poly
2 3
###
###
perm
1 4 2 3 
perm
2 3 4 1 
perm
2 4 1 3 
perm
2 1 3 4...

result:

ok good communication process (42 test cases)

Test #4:

score: 100
Accepted
time: 1ms
memory: 4000kb

input:

5 126
poly
3 3
.##
##.
##.
poly
3 3
..#
.##
##.
poly
3 3
###
###
##.
poly
2 4
.###
###.
poly
3 3
..#
.##
###
poly
4 2
.#
.#
##
#.
poly
2 4
####
####
poly
4 2
.#
##
#.
#.
poly
3 3
###
##.
#..
poly
2 4
####
##..
poly
4 2
##
##
##
##
poly
4 2
##
#.
#.
#.
poly
3 3
.##
.##
###
poly
2 4
..##
###.
poly
4 2...

output:

5 126
perm
2 3 1 5 4 
triang
1 2 6
1 6 7
2 3 4
2 4 6
4 5 6
triang
1 2 3
1 3 7
3 4 5
3 5 7
5 6 7
triang
1 2 3
1 3 6
1 6 7
3 4 5
3 5 6
perm
3 4 1 5 2 
triang
1 2 7
2 3 4
2 4 5
2 5 7
5 6 7
triang
1 2 4
1 4 5
1 5 7
2 3 4
5 6 7
triang
1 2 7
2 3 7
3 4 5
3 5 7
5 6 7
triang
1 2 7
2 3 4
2 4 7
4 5 6
4 6 7
tri...

input:

5 126
perm
2 3 1 5 4
triang
1 2 6
1 6 7
2 3 4
2 4 6
4 5 6
triang
1 2 3
1 3 7
3 4 5
3 5 7
5 6 7
triang
1 2 3
1 3 6
1 6 7
3 4 5
3 5 6
perm
3 4 1 5 2
triang
1 2 7
2 3 4
2 4 5
2 5 7
5 6 7
triang
1 2 4
1 4 5
1 5 7
2 3 4
5 6 7
triang
1 2 7
2 3 7
3 4 5
3 5 7
5 6 7
triang
1 2 7
2 3 4
2 4 7
4 5 6
4 6 7
trian...

output:

5 126
poly
3 3
.##
##.
##.
poly
3 3
..#
.##
##.
poly
3 3
###
###
##.
poly
2 4
.###
###.
poly
3 3
..#
.##
###
poly
4 2
.#
.#
##
#.
poly
2 4
####
####
poly
4 2
.#
##
#.
#.
poly
3 3
###
##.
#..
poly
2 4
####
##..
poly
4 2
##
##
##
##
poly
4 2
##
#.
#.
#.
poly
3 3
.##
.##
###
poly
2 4
..##
###.
poly
4 2...

result:

ok good communication process (126 test cases)

Test #5:

score: 100
Accepted
time: 1ms
memory: 3848kb

input:

6 396
poly
5 2
.#
.#
.#
##
##
poly
3 4
..##
####
###.
poly
3 4
.###
.##.
##..
poly
4 3
.##
###
###
###
poly
4 3
..#
.##
##.
##.
poly
3 4
.###
.#..
##..
poly
2 5
..###
#####
poly
4 3
..#
###
###
#..
poly
3 4
..##
.###
###.
poly
2 5
.####
###..
poly
3 4
...#
####
####
poly
3 4
####
####
###.
poly
4 3
...

output:

6 396
perm
2 3 4 1 6 5 
triang
1 2 3
1 3 6
1 6 8
3 4 5
3 5 6
6 7 8
triang
1 2 7
1 7 8
2 3 4
2 4 7
4 5 6
4 6 7
triang
1 2 4
1 4 8
2 3 4
4 5 8
5 6 8
6 7 8
triang
1 2 3
1 3 4
1 4 8
4 5 7
4 7 8
5 6 7
perm
3 1 5 2 4 6 
perm
5 1 2 3 4 6 
triang
1 2 8
2 3 6
2 6 8
3 4 5
3 5 6
6 7 8
triang
1 2 4
1 4 7
1 7 8
...

input:

6 396
perm
2 3 4 1 6 5
triang
1 2 3
1 3 6
1 6 8
3 4 5
3 5 6
6 7 8
triang
1 2 7
1 7 8
2 3 4
2 4 7
4 5 6
4 6 7
triang
1 2 4
1 4 8
2 3 4
4 5 8
5 6 8
6 7 8
triang
1 2 3
1 3 4
1 4 8
4 5 7
4 7 8
5 6 7
perm
3 1 5 2 4 6
perm
5 1 2 3 4 6
triang
1 2 8
2 3 6
2 6 8
3 4 5
3 5 6
6 7 8
triang
1 2 4
1 4 7
1 7 8
2 3...

output:

6 396
poly
5 2
.#
.#
.#
##
##
poly
3 4
..##
####
###.
poly
3 4
.###
.##.
##..
poly
4 3
.##
###
###
###
poly
4 3
..#
.##
##.
##.
poly
3 4
.###
.#..
##..
poly
2 5
..###
#####
poly
4 3
..#
###
###
#..
poly
3 4
..##
.###
###.
poly
2 5
.####
###..
poly
3 4
...#
####
####
poly
3 4
####
####
###.
poly
4 3
...

result:

ok good communication process (396 test cases)

Test #6:

score: 100
Accepted
time: 3ms
memory: 3860kb

input:

8 1000
poly
6 3
..#
..#
###
###
###
###
poly
5 4
.###
.###
.##.
###.
###.
poly
5 4
.###
####
###.
###.
##..
poly
5 4
####
####
####
####
###.
poly
4 5
..###
#####
#####
#####
poly
6 3
###
###
###
###
###
###
poly
4 5
.####
#####
##...
##...
poly
5 4
####
##..
##..
##..
##..
poly
4 5
....#
#####
####...

output:

8 1000
perm
2 3 4 1 5 7 8 6 
triang
1 2 4
1 4 5
1 5 7
1 7 10
2 3 4
5 6 7
7 8 9
7 9 10
triang
1 2 3
1 3 10
3 4 6
3 6 10
4 5 6
6 7 10
7 8 9
7 9 10
perm
2 3 1 7 4 8 5 6 
perm
2 4 1 3 6 5 7 8 
perm
2 3 1 6 7 4 5 8 
triang
1 2 3
1 3 10
3 4 9
3 9 10
4 5 6
4 6 8
4 8 9
6 7 8
perm
2 1 3 4 6 8 5 7 
triang
1 2...

input:

8 1000
perm
2 3 4 1 5 7 8 6
triang
1 2 4
1 4 5
1 5 7
1 7 10
2 3 4
5 6 7
7 8 9
7 9 10
triang
1 2 3
1 3 10
3 4 6
3 6 10
4 5 6
6 7 10
7 8 9
7 9 10
perm
2 3 1 7 4 8 5 6
perm
2 4 1 3 6 5 7 8
perm
2 3 1 6 7 4 5 8
triang
1 2 3
1 3 10
3 4 9
3 9 10
4 5 6
4 6 8
4 8 9
6 7 8
perm
2 1 3 4 6 8 5 7
triang
1 2 4
1 ...

output:

8 1000
poly
6 3
..#
..#
###
###
###
###
poly
5 4
.###
.###
.##.
###.
###.
poly
5 4
.###
####
###.
###.
##..
poly
5 4
####
####
####
####
###.
poly
4 5
..###
#####
#####
#####
poly
6 3
###
###
###
###
###
###
poly
4 5
.####
#####
##...
##...
poly
5 4
####
##..
##..
##..
##..
poly
4 5
....#
#####
####...

result:

ok good communication process (1000 test cases)

Test #7:

score: 100
Accepted
time: 2ms
memory: 3988kb

input:

2 1000
triang
1 2 3
1 3 4
perm
1 2
poly
2 1
#
#
poly
1 2
##
perm
2 1
poly
1 2
##
poly
1 2
##
perm
1 2
perm
2 1
triang
1 2 3
1 3 4
perm
2 1
poly
2 1
#
#
perm
2 1
perm
2 1
poly
1 2
##
perm
1 2
poly
2 1
#
#
poly
1 2
##
triang
1 2 4
2 3 4
triang
1 2 4
2 3 4
perm
2 1
poly
2 1
#
#
triang
1 2 3
1 3 4
poly
...

output:

2 1000
perm
2 1 
poly
2 1
#
#
perm
1 2 
triang
1 2 4
2 3 4
triang
1 2 3
1 3 4
triang
1 2 4
2 3 4
triang
1 2 4
2 3 4
poly
2 1
#
#
triang
1 2 3
1 3 4
perm
2 1 
triang
1 2 3
1 3 4
perm
1 2 
triang
1 2 3
1 3 4
triang
1 2 3
1 3 4
triang
1 2 4
2 3 4
poly
2 1
#
#
perm
1 2 
triang
1 2 4
2 3 4
poly
1 2
##
po...

input:

2 1000
perm
2 1
poly
2 1
#
#
perm
1 2
triang
1 2 4
2 3 4
triang
1 2 3
1 3 4
triang
1 2 4
2 3 4
triang
1 2 4
2 3 4
poly
2 1
#
#
triang
1 2 3
1 3 4
perm
2 1
triang
1 2 3
1 3 4
perm
1 2
triang
1 2 3
1 3 4
triang
1 2 3
1 3 4
triang
1 2 4
2 3 4
poly
2 1
#
#
perm
1 2
triang
1 2 4
2 3 4
poly
1 2
##
poly
1 ...

output:

2 1000
triang
1 2 3
1 3 4
perm
1 2 
poly
2 1
#
#
poly
1 2
##
perm
2 1 
poly
1 2
##
poly
1 2
##
perm
1 2 
perm
2 1 
triang
1 2 3
1 3 4
perm
2 1 
poly
2 1
#
#
perm
2 1 
perm
2 1 
poly
1 2
##
perm
1 2 
poly
2 1
#
#
poly
1 2
##
triang
1 2 4
2 3 4
triang
1 2 4
2 3 4
perm
2 1 
poly
2 1
#
#
triang
1 2 3
1 ...

result:

ok good communication process (1000 test cases)

Test #8:

score: 100
Accepted
time: 2ms
memory: 4104kb

input:

4 1000
perm
3 1 2 4
triang
1 2 6
2 3 6
3 4 6
4 5 6
poly
2 3
.##
###
perm
3 1 4 2
perm
1 3 4 2
poly
2 3
..#
###
poly
3 2
##
##
##
poly
2 3
###
#..
perm
1 3 2 4
triang
1 2 3
1 3 4
1 4 6
4 5 6
poly
3 2
.#
##
##
poly
4 1
#
#
#
#
perm
2 4 1 3
perm
3 4 1 2
triang
1 2 4
1 4 6
2 3 4
4 5 6
perm
1 3 4 2
poly
...

output:

4 1000
poly
2 3
.##
##.
poly
3 2
##
#.
#.
triang
1 2 5
1 5 6
2 3 4
2 4 5
triang
1 2 3
1 3 5
1 5 6
3 4 5
triang
1 2 6
2 3 5
2 5 6
3 4 5
perm
3 4 1 2 
triang
1 2 6
2 3 4
2 4 5
2 5 6
perm
1 4 2 3 
poly
3 2
##
##
#.
poly
3 2
.#
.#
##
perm
2 1 4 3 
perm
1 2 3 4 
triang
1 2 5
1 5 6
2 3 5
3 4 5
poly
2 3
.....

input:

4 1000
poly
2 3
.##
##.
poly
3 2
##
#.
#.
triang
1 2 5
1 5 6
2 3 4
2 4 5
triang
1 2 3
1 3 5
1 5 6
3 4 5
triang
1 2 6
2 3 5
2 5 6
3 4 5
perm
3 4 1 2
triang
1 2 6
2 3 4
2 4 5
2 5 6
perm
1 4 2 3
poly
3 2
##
##
#.
poly
3 2
.#
.#
##
perm
2 1 4 3
perm
1 2 3 4
triang
1 2 5
1 5 6
2 3 5
3 4 5
poly
2 3
..#
##...

output:

4 1000
perm
3 1 2 4 
triang
1 2 6
2 3 6
3 4 6
4 5 6
poly
2 3
.##
###
perm
3 1 4 2 
perm
1 3 4 2 
poly
2 3
..#
###
poly
3 2
##
##
##
poly
2 3
###
#..
perm
1 3 2 4 
triang
1 2 3
1 3 4
1 4 6
4 5 6
poly
3 2
.#
##
##
poly
4 1
#
#
#
#
perm
2 4 1 3 
perm
3 4 1 2 
triang
1 2 4
1 4 6
2 3 4
4 5 6
perm
1 3 4 2...

result:

ok good communication process (1000 test cases)

Test #9:

score: 100
Accepted
time: 2ms
memory: 3984kb

input:

5 1000
perm
2 3 4 5 1
triang
1 2 3
1 3 6
1 6 7
3 4 5
3 5 6
triang
1 2 7
2 3 4
2 4 5
2 5 6
2 6 7
triang
1 2 3
1 3 6
1 6 7
3 4 6
4 5 6
triang
1 2 7
2 3 4
2 4 5
2 5 6
2 6 7
perm
2 1 4 5 3
perm
3 1 4 2 5
perm
5 1 2 3 4
poly
4 2
.#
##
##
#.
triang
1 2 3
1 3 7
3 4 7
4 5 7
5 6 7
triang
1 2 4
1 4 7
2 3 4
4 ...

output:

5 1000
poly
3 3
..#
###
##.
poly
2 4
.###
###.
perm
1 5 2 3 4 
perm
3 4 1 2 5 
perm
1 5 2 3 4 
triang
1 2 3
1 3 7
3 4 6
3 6 7
4 5 6
poly
3 3
.##
.##
##.
triang
1 2 3
1 3 4
1 4 5
1 5 6
1 6 7
perm
1 3 2 5 4 
poly
4 2
.#
##
##
##
poly
3 3
.##
###
##.
perm
1 3 4 2 5 
perm
1 3 5 2 4 
triang
1 2 6
1 6 7
2...

input:

5 1000
poly
3 3
..#
###
##.
poly
2 4
.###
###.
perm
1 5 2 3 4
perm
3 4 1 2 5
perm
1 5 2 3 4
triang
1 2 3
1 3 7
3 4 6
3 6 7
4 5 6
poly
3 3
.##
.##
##.
triang
1 2 3
1 3 4
1 4 5
1 5 6
1 6 7
perm
1 3 2 5 4
poly
4 2
.#
##
##
##
poly
3 3
.##
###
##.
perm
1 3 4 2 5
perm
1 3 5 2 4
triang
1 2 6
1 6 7
2 3 5
2...

output:

5 1000
perm
2 3 4 5 1 
triang
1 2 3
1 3 6
1 6 7
3 4 5
3 5 6
triang
1 2 7
2 3 4
2 4 5
2 5 6
2 6 7
triang
1 2 3
1 3 6
1 6 7
3 4 6
4 5 6
triang
1 2 7
2 3 4
2 4 5
2 5 6
2 6 7
perm
2 1 4 5 3 
perm
3 1 4 2 5 
perm
5 1 2 3 4 
poly
4 2
.#
##
##
#.
triang
1 2 3
1 3 7
3 4 7
4 5 7
5 6 7
triang
1 2 4
1 4 7
2 3 ...

result:

ok good communication process (1000 test cases)

Test #10:

score: 100
Accepted
time: 3ms
memory: 4004kb

input:

6 1000
perm
6 1 2 3 4 5
triang
1 2 3
1 3 5
1 5 8
3 4 5
5 6 8
6 7 8
triang
1 2 5
1 5 6
1 6 8
2 3 4
2 4 5
6 7 8
poly
4 3
..#
.##
.#.
##.
poly
4 3
.##
.##
###
#..
triang
1 2 3
1 3 4
1 4 5
1 5 6
1 6 8
6 7 8
poly
3 4
####
##..
##..
perm
1 4 2 5 6 3
triang
1 2 3
1 3 7
1 7 8
3 4 6
3 6 7
4 5 6
poly
4 3
###
...

output:

6 1000
triang
1 2 3
1 3 4
1 4 5
1 5 6
1 6 7
1 7 8
poly
4 3
..#
..#
###
##.
poly
3 4
...#
####
####
triang
1 2 7
1 7 8
2 3 7
3 4 5
3 5 7
5 6 7
triang
1 2 8
2 3 7
2 7 8
3 4 5
3 5 6
3 6 7
perm
3 1 4 2 5 6 
triang
1 2 3
1 3 8
3 4 5
3 5 6
3 6 8
6 7 8
triang
1 2 8
2 3 7
2 7 8
3 4 6
3 6 7
4 5 6
perm
3 5 1 ...

input:

6 1000
triang
1 2 3
1 3 4
1 4 5
1 5 6
1 6 7
1 7 8
poly
4 3
..#
..#
###
##.
poly
3 4
...#
####
####
triang
1 2 7
1 7 8
2 3 7
3 4 5
3 5 7
5 6 7
triang
1 2 8
2 3 7
2 7 8
3 4 5
3 5 6
3 6 7
perm
3 1 4 2 5 6
triang
1 2 3
1 3 8
3 4 5
3 5 6
3 6 8
6 7 8
triang
1 2 8
2 3 7
2 7 8
3 4 6
3 6 7
4 5 6
perm
3 5 1 2...

output:

6 1000
perm
6 1 2 3 4 5 
triang
1 2 3
1 3 5
1 5 8
3 4 5
5 6 8
6 7 8
triang
1 2 5
1 5 6
1 6 8
2 3 4
2 4 5
6 7 8
poly
4 3
..#
.##
.#.
##.
poly
4 3
.##
.##
###
#..
triang
1 2 3
1 3 4
1 4 5
1 5 6
1 6 8
6 7 8
poly
3 4
####
##..
##..
perm
1 4 2 5 6 3 
triang
1 2 3
1 3 7
1 7 8
3 4 6
3 6 7
4 5 6
poly
4 3
##...

result:

ok good communication process (1000 test cases)

Test #11:

score: 100
Accepted
time: 3ms
memory: 3804kb

input:

8 1000
triang
1 2 3
1 3 10
3 4 5
3 5 9
3 9 10
5 6 8
5 8 9
6 7 8
triang
1 2 3
1 3 4
1 4 6
1 6 7
1 7 8
1 8 9
1 9 10
4 5 6
poly
4 5
...##
..##.
.###.
###..
perm
3 1 2 6 4 5 7 8
triang
1 2 6
1 6 10
2 3 4
2 4 6
4 5 6
6 7 8
6 8 10
8 9 10
triang
1 2 3
1 3 7
1 7 10
3 4 7
4 5 6
4 6 7
7 8 10
8 9 10
perm
2 5 1...

output:

8 1000
poly
5 4
..##
..##
####
##..
##..
poly
3 6
.....#
.....#
######
perm
4 1 6 2 3 7 8 5 
poly
5 4
...#
.###
.###
####
####
perm
2 4 1 6 7 3 8 5 
perm
2 5 6 1 3 8 4 7 
triang
1 2 3
1 3 4
1 4 5
1 5 6
1 6 10
6 7 9
6 9 10
7 8 9
perm
3 1 4 2 7 8 5 6 
triang
1 2 10
2 3 6
2 6 10
3 4 5
3 5 6
6 7 8
6 8 1...

input:

8 1000
poly
5 4
..##
..##
####
##..
##..
poly
3 6
.....#
.....#
######
perm
4 1 6 2 3 7 8 5
poly
5 4
...#
.###
.###
####
####
perm
2 4 1 6 7 3 8 5
perm
2 5 6 1 3 8 4 7
triang
1 2 3
1 3 4
1 4 5
1 5 6
1 6 10
6 7 9
6 9 10
7 8 9
perm
3 1 4 2 7 8 5 6
triang
1 2 10
2 3 6
2 6 10
3 4 5
3 5 6
6 7 8
6 8 10
8 ...

output:

8 1000
triang
1 2 3
1 3 10
3 4 5
3 5 9
3 9 10
5 6 8
5 8 9
6 7 8
triang
1 2 3
1 3 4
1 4 6
1 6 7
1 7 8
1 8 9
1 9 10
4 5 6
poly
4 5
...##
..##.
.###.
###..
perm
3 1 2 6 4 5 7 8 
triang
1 2 6
1 6 10
2 3 4
2 4 6
4 5 6
6 7 8
6 8 10
8 9 10
triang
1 2 3
1 3 7
1 7 10
3 4 7
4 5 6
4 6 7
7 8 10
8 9 10
perm
2 5 ...

result:

ok good communication process (1000 test cases)

Test #12:

score: 100
Accepted
time: 4ms
memory: 3816kb

input:

9 1000
triang
1 2 8
1 8 11
2 3 8
3 4 6
3 6 7
3 7 8
4 5 6
8 9 10
8 10 11
poly
5 5
....#
...##
.####
###..
#....
poly
6 4
.###
.###
.###
.##.
.##.
##..
perm
3 1 2 5 4 6 7 8 9
poly
6 4
...#
..##
.###
####
####
#...
poly
3 7
.######
.####..
##.....
perm
4 5 1 7 2 3 8 9 6
perm
2 1 5 3 4 8 6 7 9
poly
5 5
...

output:

9 1000
poly
5 5
....#
....#
..###
###..
##...
perm
1 5 2 8 3 9 4 6 7 
perm
3 4 7 1 8 2 5 6 9 
poly
5 5
....#
.####
.###.
###..
###..
perm
1 4 2 3 7 8 5 9 6 
perm
3 5 7 1 2 4 6 8 9 
triang
1 2 7
1 7 10
1 10 11
2 3 5
2 5 7
3 4 5
5 6 7
7 8 10
8 9 10
poly
4 6
######
######
######
##....
triang
1 2 11
2 ...

input:

9 1000
poly
5 5
....#
....#
..###
###..
##...
perm
1 5 2 8 3 9 4 6 7
perm
3 4 7 1 8 2 5 6 9
poly
5 5
....#
.####
.###.
###..
###..
perm
1 4 2 3 7 8 5 9 6
perm
3 5 7 1 2 4 6 8 9
triang
1 2 7
1 7 10
1 10 11
2 3 5
2 5 7
3 4 5
5 6 7
7 8 10
8 9 10
poly
4 6
######
######
######
##....
triang
1 2 11
2 3 10...

output:

9 1000
triang
1 2 8
1 8 11
2 3 8
3 4 6
3 6 7
3 7 8
4 5 6
8 9 10
8 10 11
poly
5 5
....#
...##
.####
###..
#....
poly
6 4
.###
.###
.###
.##.
.##.
##..
perm
3 1 2 5 4 6 7 8 9 
poly
6 4
...#
..##
.###
####
####
#...
poly
3 7
.######
.####..
##.....
perm
4 5 1 7 2 3 8 9 6 
perm
2 1 5 3 4 8 6 7 9 
poly
5...

result:

ok good communication process (1000 test cases)

Test #13:

score: 100
Accepted
time: 4ms
memory: 4100kb

input:

10 1000
perm
5 7 1 2 8 3 4 10 6 9
poly
6 5
....#
..###
.####
####.
####.
#....
poly
4 7
.....##
#######
######.
######.
perm
2 1 3 5 4 8 9 10 6 7
triang
1 2 11
1 11 12
2 3 8
2 8 11
3 4 5
3 5 6
3 6 8
6 7 8
8 9 10
8 10 11
perm
1 8 2 3 9 4 10 5 6 7
perm
4 1 7 8 2 9 3 10 5 6
perm
6 1 2 7 3 4 8 10 5 9
tr...

output:

10 1000
triang
1 2 5
1 5 10
1 10 11
1 11 12
2 3 4
2 4 5
5 6 8
5 8 9
5 9 10
6 7 8
triang
1 2 12
2 3 10
2 10 12
3 4 7
3 7 10
4 5 7
5 6 7
7 8 9
7 9 10
10 11 12
triang
1 2 7
1 7 12
2 3 4
2 4 7
4 5 6
4 6 7
7 8 9
7 9 12
9 10 11
9 11 12
triang
1 2 3
1 3 12
3 4 12
4 5 6
4 6 12
6 7 9
6 9 11
6 11 12
7 8 9
9 1...

input:

10 1000
triang
1 2 5
1 5 10
1 10 11
1 11 12
2 3 4
2 4 5
5 6 8
5 8 9
5 9 10
6 7 8
triang
1 2 12
2 3 10
2 10 12
3 4 7
3 7 10
4 5 7
5 6 7
7 8 9
7 9 10
10 11 12
triang
1 2 7
1 7 12
2 3 4
2 4 7
4 5 6
4 6 7
7 8 9
7 9 12
9 10 11
9 11 12
triang
1 2 3
1 3 12
3 4 12
4 5 6
4 6 12
6 7 9
6 9 11
6 11 12
7 8 9
9 1...

output:

10 1000
perm
5 7 1 2 8 3 4 10 6 9 
poly
6 5
....#
..###
.####
####.
####.
#....
poly
4 7
.....##
#######
######.
######.
perm
2 1 3 5 4 8 9 10 6 7 
triang
1 2 11
1 11 12
2 3 8
2 8 11
3 4 5
3 5 6
3 6 8
6 7 8
8 9 10
8 10 11
perm
1 8 2 3 9 4 10 5 6 7 
perm
4 1 7 8 2 9 3 10 5 6 
perm
6 1 2 7 3 4 8 10 5 ...

result:

ok good communication process (1000 test cases)

Test #14:

score: 100
Accepted
time: 4ms
memory: 3884kb

input:

11 1000
triang
1 2 13
2 3 12
2 12 13
3 4 7
3 7 8
3 8 12
4 5 7
5 6 7
8 9 11
8 11 12
9 10 11
perm
2 1 4 3 6 5 9 10 11 7 8
poly
7 5
..###
..###
.####
.#...
##...
#....
#....
triang
1 2 4
1 4 12
1 12 13
2 3 4
4 5 11
4 11 12
5 6 11
6 7 8
6 8 11
8 9 10
8 10 11
perm
4 7 1 8 2 3 10 5 6 9 11
triang
1 2 13
2 ...

output:

11 1000
perm
1 4 6 9 2 3 5 10 7 8 11 
triang
1 2 3
1 3 13
3 4 5
3 5 13
5 6 7
5 7 13
7 8 10
7 10 12
7 12 13
8 9 10
10 11 12
perm
1 2 5 6 8 9 3 4 7 11 10 
perm
4 1 7 2 3 8 9 5 6 10 11 
triang
1 2 7
1 7 9
1 9 12
1 12 13
2 3 7
3 4 7
4 5 6
4 6 7
7 8 9
9 10 11
9 11 12
poly
8 4
...#
.###
.##.
.#..
##..
#.....

input:

11 1000
perm
1 4 6 9 2 3 5 10 7 8 11
triang
1 2 3
1 3 13
3 4 5
3 5 13
5 6 7
5 7 13
7 8 10
7 10 12
7 12 13
8 9 10
10 11 12
perm
1 2 5 6 8 9 3 4 7 11 10
perm
4 1 7 2 3 8 9 5 6 10 11
triang
1 2 7
1 7 9
1 9 12
1 12 13
2 3 7
3 4 7
4 5 6
4 6 7
7 8 9
9 10 11
9 11 12
poly
8 4
...#
.###
.##.
.#..
##..
#...
#...

output:

11 1000
triang
1 2 13
2 3 12
2 12 13
3 4 7
3 7 8
3 8 12
4 5 7
5 6 7
8 9 11
8 11 12
9 10 11
perm
2 1 4 3 6 5 9 10 11 7 8 
poly
7 5
..###
..###
.####
.#...
##...
#....
#....
triang
1 2 4
1 4 12
1 12 13
2 3 4
4 5 11
4 11 12
5 6 11
6 7 8
6 8 11
8 9 10
8 10 11
perm
4 7 1 8 2 3 10 5 6 9 11 
triang
1 2 13
...

result:

ok good communication process (1000 test cases)

Test #15:

score: 100
Accepted
time: 5ms
memory: 4088kb

input:

12 1000
triang
1 2 4
1 4 5
1 5 14
2 3 4
5 6 7
5 7 14
7 8 9
7 9 14
9 10 14
10 11 13
10 13 14
11 12 13
triang
1 2 12
1 12 14
2 3 4
2 4 12
4 5 11
4 11 12
5 6 11
6 7 9
6 9 11
7 8 9
9 10 11
12 13 14
perm
4 5 1 6 2 7 9 10 11 12 3 8
perm
1 2 4 6 7 3 5 9 8 10 12 11
poly
7 6
...###
.####.
.####.
.####.
####....

output:

12 1000
poly
6 7
.....##
...###.
######.
######.
######.
###....
poly
6 7
......#
.....##
..####.
.####..
####...
####...
triang
1 2 3
1 3 4
1 4 13
1 13 14
4 5 9
4 9 10
4 10 13
5 6 7
5 7 8
5 8 9
10 11 13
11 12 13
poly
7 6
...###
.#####
#####.
#####.
####..
#.....
#.....
perm
1 4 2 6 7 3 12 5 8 9 10 ...

input:

12 1000
poly
6 7
.....##
...###.
######.
######.
######.
###....
poly
6 7
......#
.....##
..####.
.####..
####...
####...
triang
1 2 3
1 3 4
1 4 13
1 13 14
4 5 9
4 9 10
4 10 13
5 6 7
5 7 8
5 8 9
10 11 13
11 12 13
poly
7 6
...###
.#####
#####.
#####.
####..
#.....
#.....
perm
1 4 2 6 7 3 12 5 8 9 10 ...

output:

12 1000
triang
1 2 4
1 4 5
1 5 14
2 3 4
5 6 7
5 7 14
7 8 9
7 9 14
9 10 14
10 11 13
10 13 14
11 12 13
triang
1 2 12
1 12 14
2 3 4
2 4 12
4 5 11
4 11 12
5 6 11
6 7 9
6 9 11
7 8 9
9 10 11
12 13 14
perm
4 5 1 6 2 7 9 10 11 12 3 8 
perm
1 2 4 6 7 3 5 9 8 10 12 11 
poly
7 6
...###
.####.
.####.
.####.
###...

result:

ok good communication process (1000 test cases)

Test #16:

score: 100
Accepted
time: 5ms
memory: 4060kb

input:

13 1000
perm
3 5 8 9 1 2 4 6 7 11 10 13 12
triang
1 2 3
1 3 15
3 4 5
3 5 10
3 10 11
3 11 15
5 6 9
5 9 10
6 7 8
6 8 9
11 12 15
12 13 15
13 14 15
poly
4 10
......####
.######...
#######...
#####.....
perm
5 1 2 3 6 4 10 7 11 12 8 13 9
poly
6 8
......##
....####
....###.
.######.
#####...
##......
poly...

output:

13 1000
triang
1 2 14
1 14 15
2 3 14
3 4 5
3 5 14
5 6 7
5 7 8
5 8 9
5 9 14
9 10 14
10 11 12
10 12 14
12 13 14
poly
8 6
.....#
..####
..####
#####.
#####.
#####.
####..
##....
triang
1 2 13
1 13 15
2 3 4
2 4 10
2 10 12
2 12 13
4 5 10
5 6 7
5 7 9
5 9 10
7 8 9
10 11 12
13 14 15
poly
7 7
....###
....#.....

input:

13 1000
triang
1 2 14
1 14 15
2 3 14
3 4 5
3 5 14
5 6 7
5 7 8
5 8 9
5 9 14
9 10 14
10 11 12
10 12 14
12 13 14
poly
8 6
.....#
..####
..####
#####.
#####.
#####.
####..
##....
triang
1 2 13
1 13 15
2 3 4
2 4 10
2 10 12
2 12 13
4 5 10
5 6 7
5 7 9
5 9 10
7 8 9
10 11 12
13 14 15
poly
7 7
....###
....#.....

output:

13 1000
perm
3 5 8 9 1 2 4 6 7 11 10 13 12 
triang
1 2 3
1 3 15
3 4 5
3 5 10
3 10 11
3 11 15
5 6 9
5 9 10
6 7 8
6 8 9
11 12 15
12 13 15
13 14 15
poly
4 10
......####
.######...
#######...
#####.....
perm
5 1 2 3 6 4 10 7 11 12 8 13 9 
poly
6 8
......##
....####
....###.
.######.
#####...
##......
po...

result:

ok good communication process (1000 test cases)

Test #17:

score: 100
Accepted
time: 5ms
memory: 3904kb

input:

14 1000
perm
5 6 1 8 2 9 3 4 11 13 14 7 10 12
triang
1 2 3
1 3 8
1 8 10
1 10 16
3 4 5
3 5 8
5 6 7
5 7 8
8 9 10
10 11 16
11 12 13
11 13 16
13 14 16
14 15 16
poly
9 6
.....#
....##
....##
..####
..####
.#####
####..
####..
#.....
triang
1 2 3
1 3 11
1 11 12
1 12 14
1 14 16
3 4 11
4 5 8
4 8 11
5 6 8
6 ...

output:

14 1000
triang
1 2 7
1 7 12
1 12 13
1 13 15
1 15 16
2 3 4
2 4 7
4 5 6
4 6 7
7 8 10
7 10 12
8 9 10
10 11 12
13 14 15
perm
2 6 7 8 1 9 11 12 3 4 5 10 13 14 
triang
1 2 16
2 3 14
2 14 16
3 4 14
4 5 12
4 12 13
4 13 14
5 6 12
6 7 11
6 11 12
7 8 11
8 9 10
8 10 11
14 15 16
perm
3 5 1 6 8 9 2 11 12 13 4 7 1...

input:

14 1000
triang
1 2 7
1 7 12
1 12 13
1 13 15
1 15 16
2 3 4
2 4 7
4 5 6
4 6 7
7 8 10
7 10 12
8 9 10
10 11 12
13 14 15
perm
2 6 7 8 1 9 11 12 3 4 5 10 13 14
triang
1 2 16
2 3 14
2 14 16
3 4 14
4 5 12
4 12 13
4 13 14
5 6 12
6 7 11
6 11 12
7 8 11
8 9 10
8 10 11
14 15 16
perm
3 5 1 6 8 9 2 11 12 13 4 7 14...

output:

14 1000
perm
5 6 1 8 2 9 3 4 11 13 14 7 10 12 
triang
1 2 3
1 3 8
1 8 10
1 10 16
3 4 5
3 5 8
5 6 7
5 7 8
8 9 10
10 11 16
11 12 13
11 13 16
13 14 16
14 15 16
poly
9 6
.....#
....##
....##
..####
..####
.#####
####..
####..
#.....
triang
1 2 3
1 3 11
1 11 12
1 12 14
1 14 16
3 4 11
4 5 8
4 8 11
5 6 8
6...

result:

ok good communication process (1000 test cases)

Test #18:

score: 100
Accepted
time: 6ms
memory: 3900kb

input:

16 1000
poly
9 8
....####
....####
....##..
....#...
..###...
.####...
.####...
####....
##......
poly
7 10
.........#
.......###
......####
..#####...
..###.....
.####.....
##........
poly
9 8
.......#
.#######
.#######
########
#####...
####....
####....
####....
#.......
triang
1 2 18
2 3 18
3 4 ...

output:

16 1000
triang
1 2 3
1 3 13
1 13 18
3 4 5
3 5 13
5 6 7
5 7 11
5 11 12
5 12 13
7 8 11
8 9 11
9 10 11
13 14 16
13 16 18
14 15 16
16 17 18
triang
1 2 17
1 17 18
2 3 6
2 6 8
2 8 16
2 16 17
3 4 5
3 5 6
6 7 8
8 9 16
9 10 16
10 11 16
11 12 16
12 13 15
12 15 16
13 14 15
perm
1 3 5 2 4 10 11 12 6 13 15 16 7 ...

input:

16 1000
triang
1 2 3
1 3 13
1 13 18
3 4 5
3 5 13
5 6 7
5 7 11
5 11 12
5 12 13
7 8 11
8 9 11
9 10 11
13 14 16
13 16 18
14 15 16
16 17 18
triang
1 2 17
1 17 18
2 3 6
2 6 8
2 8 16
2 16 17
3 4 5
3 5 6
6 7 8
8 9 16
9 10 16
10 11 16
11 12 16
12 13 15
12 15 16
13 14 15
perm
1 3 5 2 4 10 11 12 6 13 15 16 7 ...

output:

16 1000
poly
9 8
....####
....####
....##..
....#...
..###...
.####...
.####...
####....
##......
poly
7 10
.........#
.......###
......####
..#####...
..###.....
.####.....
##........
poly
9 8
.......#
.#######
.#######
########
#####...
####....
####....
####....
#.......
triang
1 2 18
2 3 18
3 4 ...

result:

ok good communication process (1000 test cases)

Test #19:

score: 100
Accepted
time: 9ms
memory: 3952kb

input:

17 1000
perm
2 1 3 6 4 10 11 5 12 15 7 8 9 13 14 17 16
triang
1 2 5
1 5 19
2 3 5
3 4 5
5 6 7
5 7 8
5 8 18
5 18 19
8 9 11
8 11 18
9 10 11
11 12 14
11 14 15
11 15 16
11 16 18
12 13 14
16 17 18
triang
1 2 3
1 3 18
1 18 19
3 4 16
3 16 18
4 5 6
4 6 9
4 9 10
4 10 11
4 11 16
6 7 9
7 8 9
11 12 14
11 14 15
1...

output:

17 1000
triang
1 2 3
1 3 19
3 4 19
4 5 6
4 6 12
4 12 13
4 13 16
4 16 19
6 7 9
6 9 11
6 11 12
7 8 9
9 10 11
13 14 15
13 15 16
16 17 18
16 18 19
poly
8 10
.........#
......####
....####..
...####...
...###....
#####.....
#####.....
##........
poly
7 11
.........##
.....#####.
.#########.
.#######...
....

input:

17 1000
triang
1 2 3
1 3 19
3 4 19
4 5 6
4 6 12
4 12 13
4 13 16
4 16 19
6 7 9
6 9 11
6 11 12
7 8 9
9 10 11
13 14 15
13 15 16
16 17 18
16 18 19
poly
8 10
.........#
......####
....####..
...####...
...###....
#####.....
#####.....
##........
poly
7 11
.........##
.....#####.
.#########.
.#######...
....

output:

17 1000
perm
2 1 3 6 4 10 11 5 12 15 7 8 9 13 14 17 16 
triang
1 2 5
1 5 19
2 3 5
3 4 5
5 6 7
5 7 8
5 8 18
5 18 19
8 9 11
8 11 18
9 10 11
11 12 14
11 14 15
11 15 16
11 16 18
12 13 14
16 17 18
triang
1 2 3
1 3 18
1 18 19
3 4 16
3 16 18
4 5 6
4 6 9
4 9 10
4 10 11
4 11 16
6 7 9
7 8 9
11 12 14
11 14 15
...

result:

ok good communication process (1000 test cases)

Test #20:

score: 100
Accepted
time: 7ms
memory: 3928kb

input:

18 1000
triang
1 2 17
1 17 19
1 19 20
2 3 4
2 4 11
2 11 13
2 13 17
4 5 6
4 6 9
4 9 10
4 10 11
6 7 9
7 8 9
11 12 13
13 14 15
13 15 16
13 16 17
17 18 19
poly
10 9
......###
......###
....####.
....####.
#####....
###......
##.......
#........
#........
#........
triang
1 2 3
1 3 11
1 11 20
3 4 5
3 5 1...

output:

18 1000
perm
5 6 7 8 1 9 2 3 10 4 12 13 14 15 16 11 17 18 
perm
1 2 3 5 6 7 9 10 12 4 13 17 8 11 14 15 18 16 
poly
10 9
.......##
.....####
.....####
....#####
.########
.#######.
.######..
#######..
######...
#####....
perm
17 18 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 
poly
8 11
.........##
..........

input:

18 1000
perm
5 6 7 8 1 9 2 3 10 4 12 13 14 15 16 11 17 18
perm
1 2 3 5 6 7 9 10 12 4 13 17 8 11 14 15 18 16
poly
10 9
.......##
.....####
.....####
....#####
.########
.#######.
.######..
#######..
######...
#####....
perm
17 18 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
poly
8 11
.........##
........##...

output:

18 1000
triang
1 2 17
1 17 19
1 19 20
2 3 4
2 4 11
2 11 13
2 13 17
4 5 6
4 6 9
4 9 10
4 10 11
6 7 9
7 8 9
11 12 13
13 14 15
13 15 16
13 16 17
17 18 19
poly
10 9
......###
......###
....####.
....####.
#####....
###......
##.......
#........
#........
#........
triang
1 2 3
1 3 11
1 11 20
3 4 5
3 5 1...

result:

ok good communication process (1000 test cases)

Test #21:

score: 100
Accepted
time: 7ms
memory: 4156kb

input:

19 1000
poly
12 8
.......#
.......#
......##
....###.
....###.
.####...
.###....
####....
##......
##......
##......
##......
poly
10 10
........##
........#.
.......##.
.......#..
...#####..
..####....
.####.....
.##.......
###.......
###.......
poly
9 11
.........##
....#######
...########
...####...

output:

19 1000
triang
1 2 3
1 3 21
3 4 21
4 5 6
4 6 21
6 7 21
7 8 15
7 15 17
7 17 18
7 18 19
7 19 21
8 9 15
9 10 15
10 11 12
10 12 15
12 13 14
12 14 15
15 16 17
19 20 21
triang
1 2 5
1 5 6
1 6 16
1 16 17
1 17 21
2 3 4
2 4 5
6 7 8
6 8 12
6 12 16
8 9 12
9 10 12
10 11 12
12 13 16
13 14 16
14 15 16
17 18 21
18...

input:

19 1000
triang
1 2 3
1 3 21
3 4 21
4 5 6
4 6 21
6 7 21
7 8 15
7 15 17
7 17 18
7 18 19
7 19 21
8 9 15
9 10 15
10 11 12
10 12 15
12 13 14
12 14 15
15 16 17
19 20 21
triang
1 2 5
1 5 6
1 6 16
1 16 17
1 17 21
2 3 4
2 4 5
6 7 8
6 8 12
6 12 16
8 9 12
9 10 12
10 11 12
12 13 16
13 14 16
14 15 16
17 18 21
18...

output:

19 1000
poly
12 8
.......#
.......#
......##
....###.
....###.
.####...
.###....
####....
##......
##......
##......
##......
poly
10 10
........##
........#.
.......##.
.......#..
...#####..
..####....
.####.....
.##.......
###.......
###.......
poly
9 11
.........##
....#######
...########
...####...

result:

ok good communication process (1000 test cases)

Test #22:

score: 100
Accepted
time: 7ms
memory: 3944kb

input:

20 1000
triang
1 2 3
1 3 21
1 21 22
3 4 17
3 17 18
3 18 19
3 19 20
3 20 21
4 5 10
4 10 11
4 11 17
5 6 10
6 7 9
6 9 10
7 8 9
11 12 13
11 13 16
11 16 17
13 14 15
13 15 16
triang
1 2 4
1 4 5
1 5 14
1 14 21
1 21 22
2 3 4
5 6 13
5 13 14
6 7 10
6 10 11
6 11 13
7 8 9
7 9 10
11 12 13
14 15 16
14 16 21
16 17...

output:

20 1000
poly
12 9
......###
......##.
......##.
......##.
.....###.
....####.
..#####..
..#####..
..####...
.##......
.##......
###......
poly
12 9
....#####
....#####
....#####
...####..
...####..
...####..
..#####..
..#####..
..#####..
..###....
.##......
###......
poly
11 10
........##
........##...

input:

20 1000
poly
12 9
......###
......##.
......##.
......##.
.....###.
....####.
..#####..
..#####..
..####...
.##......
.##......
###......
poly
12 9
....#####
....#####
....#####
...####..
...####..
...####..
..#####..
..#####..
..#####..
..###....
.##......
###......
poly
11 10
........##
........##...

output:

20 1000
triang
1 2 3
1 3 21
1 21 22
3 4 17
3 17 18
3 18 19
3 19 20
3 20 21
4 5 10
4 10 11
4 11 17
5 6 10
6 7 9
6 9 10
7 8 9
11 12 13
11 13 16
11 16 17
13 14 15
13 15 16
triang
1 2 4
1 4 5
1 5 14
1 14 21
1 21 22
2 3 4
5 6 13
5 13 14
6 7 10
6 10 11
6 11 13
7 8 9
7 9 10
11 12 13
14 15 16
14 16 21
16 17...

result:

ok good communication process (1000 test cases)

Test #23:

score: 100
Accepted
time: 8ms
memory: 4176kb

input:

21 1000
perm
2 5 1 3 6 4 12 7 16 8 9 10 11 13 18 14 15 19 17 21 20
triang
1 2 3
1 3 21
1 21 22
1 22 23
3 4 5
3 5 7
3 7 8
3 8 16
3 16 17
3 17 21
5 6 7
8 9 16
9 10 16
10 11 13
10 13 15
10 15 16
11 12 13
13 14 15
17 18 19
17 19 21
19 20 21
perm
6 1 7 9 10 2 11 3 13 16 4 5 8 17 19 12 20 14 15 18 21
tria...

output:

21 1000
poly
11 11
.......####
.......####
......#####
..#####....
..#####....
.###.......
.###.......
.###.......
####.......
###........
###........
perm
6 7 1 9 2 10 3 4 5 12 13 8 14 15 11 18 20 21 16 17 19 
poly
9 13
...........##
..........###
.........##..
.....######..
.....###.....
...####.....

input:

21 1000
poly
11 11
.......####
.......####
......#####
..#####....
..#####....
.###.......
.###.......
.###.......
####.......
###........
###........
perm
6 7 1 9 2 10 3 4 5 12 13 8 14 15 11 18 20 21 16 17 19
poly
9 13
...........##
..........###
.........##..
.....######..
.....###.....
...####......

output:

21 1000
perm
2 5 1 3 6 4 12 7 16 8 9 10 11 13 18 14 15 19 17 21 20 
triang
1 2 3
1 3 21
1 21 22
1 22 23
3 4 5
3 5 7
3 7 8
3 8 16
3 16 17
3 17 21
5 6 7
8 9 16
9 10 16
10 11 13
10 13 15
10 15 16
11 12 13
13 14 15
17 18 19
17 19 21
19 20 21
perm
6 1 7 9 10 2 11 3 13 16 4 5 8 17 19 12 20 14 15 18 21 
tr...

result:

ok good communication process (1000 test cases)

Test #24:

score: 100
Accepted
time: 8ms
memory: 3932kb

input:

22 1000
poly
11 12
.........###
.......#####
.....######.
.....#####..
.....###....
.....##.....
...###......
..####......
.####.......
.####.......
###.........
perm
1 7 2 9 3 4 10 12 14 17 5 6 19 8 11 13 20 21 15 16 18 22
perm
2 4 5 10 1 13 3 6 14 7 16 8 18 9 19 11 12 21 15 17 22 20
poly
11 12
......

output:

22 1000
triang
1 2 3
1 3 4
1 4 23
1 23 24
4 5 8
4 8 21
4 21 23
5 6 7
5 7 8
8 9 21
9 10 20
9 20 21
10 11 20
11 12 15
11 15 16
11 16 17
11 17 18
11 18 19
11 19 20
12 13 15
13 14 15
21 22 23
poly
14 9
......###
.....####
.....#...
.....#...
.....#...
...###...
...##....
...##....
...##....
...#.....
.....

input:

22 1000
triang
1 2 3
1 3 4
1 4 23
1 23 24
4 5 8
4 8 21
4 21 23
5 6 7
5 7 8
8 9 21
9 10 20
9 20 21
10 11 20
11 12 15
11 15 16
11 16 17
11 17 18
11 18 19
11 19 20
12 13 15
13 14 15
21 22 23
poly
14 9
......###
.....####
.....#...
.....#...
.....#...
...###...
...##....
...##....
...##....
...#.....
.....

output:

22 1000
poly
11 12
.........###
.......#####
.....######.
.....#####..
.....###....
.....##.....
...###......
..####......
.####.......
.####.......
###.........
perm
1 7 2 9 3 4 10 12 14 17 5 6 19 8 11 13 20 21 15 16 18 22 
perm
2 4 5 10 1 13 3 6 14 7 16 8 18 9 19 11 12 21 15 17 22 20 
poly
11 12
....

result:

ok good communication process (1000 test cases)

Test #25:

score: 100
Accepted
time: 8ms
memory: 4200kb

input:

23 1000
triang
1 2 3
1 3 25
3 4 10
3 10 11
3 11 14
3 14 15
3 15 16
3 16 19
3 19 21
3 21 25
4 5 7
4 7 8
4 8 10
5 6 7
8 9 10
11 12 14
12 13 14
16 17 19
17 18 19
19 20 21
21 22 23
21 23 24
21 24 25
poly
16 8
....####
....####
....####
....####
....####
....####
....####
....####
....####
...####.
.####...

output:

23 1000
poly
15 9
........#
........#
......###
.....####
.....###.
....###..
....###..
..#####..
######...
#####....
####.....
####.....
####.....
####.....
##.......
triang
1 2 25
2 3 11
2 11 25
3 4 8
3 8 10
3 10 11
4 5 6
4 6 8
6 7 8
8 9 10
11 12 24
11 24 25
12 13 14
12 14 16
12 16 18
12 18 24
14 ...

input:

23 1000
poly
15 9
........#
........#
......###
.....####
.....###.
....###..
....###..
..#####..
######...
#####....
####.....
####.....
####.....
####.....
##.......
triang
1 2 25
2 3 11
2 11 25
3 4 8
3 8 10
3 10 11
4 5 6
4 6 8
6 7 8
8 9 10
11 12 24
11 24 25
12 13 14
12 14 16
12 16 18
12 18 24
14 ...

output:

23 1000
triang
1 2 3
1 3 25
3 4 10
3 10 11
3 11 14
3 14 15
3 15 16
3 16 19
3 19 21
3 21 25
4 5 7
4 7 8
4 8 10
5 6 7
8 9 10
11 12 14
12 13 14
16 17 19
17 18 19
19 20 21
21 22 23
21 23 24
21 24 25
poly
16 8
....####
....####
....####
....####
....####
....####
....####
....####
....####
...####.
.####...

result:

ok good communication process (1000 test cases)

Test #26:

score: 100
Accepted
time: 9ms
memory: 4180kb

input:

24 1000
triang
1 2 3
1 3 11
1 11 17
1 17 18
1 18 19
1 19 21
1 21 26
3 4 11
4 5 6
4 6 7
4 7 11
7 8 9
7 9 10
7 10 11
11 12 13
11 13 15
11 15 17
13 14 15
15 16 17
19 20 21
21 22 24
21 24 25
21 25 26
22 23 24
triang
1 2 3
1 3 9
1 9 26
3 4 5
3 5 9
5 6 9
6 7 9
7 8 9
9 10 26
10 11 12
10 12 15
10 15 17
10 1...

output:

24 1000
poly
9 16
............####
...........#####
.......#######..
.......######...
......#######...
..########......
..###...........
###.............
##..............
perm
2 4 7 8 1 10 3 13 5 6 9 11 15 16 18 19 12 20 21 14 17 23 22 24 
perm
1 2 7 8 12 3 4 14 5 6 9 10 16 11 17 18 21 13 15 19 24 2...

input:

24 1000
poly
9 16
............####
...........#####
.......#######..
.......######...
......#######...
..########......
..###...........
###.............
##..............
perm
2 4 7 8 1 10 3 13 5 6 9 11 15 16 18 19 12 20 21 14 17 23 22 24
perm
1 2 7 8 12 3 4 14 5 6 9 10 16 11 17 18 21 13 15 19 24 20...

output:

24 1000
triang
1 2 3
1 3 11
1 11 17
1 17 18
1 18 19
1 19 21
1 21 26
3 4 11
4 5 6
4 6 7
4 7 11
7 8 9
7 9 10
7 10 11
11 12 13
11 13 15
11 15 17
13 14 15
15 16 17
19 20 21
21 22 24
21 24 25
21 25 26
22 23 24
triang
1 2 3
1 3 9
1 9 26
3 4 5
3 5 9
5 6 9
6 7 9
7 8 9
9 10 26
10 11 12
10 12 15
10 15 17
10 1...

result:

ok good communication process (1000 test cases)

Test #27:

score: 100
Accepted
time: 9ms
memory: 4228kb

input:

25 1000
poly
16 10
.........#
........##
......####
.....#####
....######
...#######
...#######
...######.
...######.
..####....
..####....
..###.....
..###.....
####......
###.......
##........
triang
1 2 6
1 6 7
1 7 8
1 8 11
1 11 13
1 13 14
1 14 18
1 18 19
1 19 25
1 25 27
2 3 4
2 4 5
2 5 6
8 9 11
...

output:

25 1000
perm
2 3 5 1 8 4 6 10 12 14 15 7 9 17 11 13 18 19 16 23 20 24 21 25 22 
perm
3 6 12 1 13 14 16 17 18 2 4 5 20 7 8 21 23 9 10 11 15 19 22 25 24 
perm
1 3 2 5 7 9 4 6 8 11 20 10 12 22 23 13 14 24 15 16 17 25 18 19 21 
poly
15 11
.........##
........###
........###
......#####
......#####
........

input:

25 1000
perm
2 3 5 1 8 4 6 10 12 14 15 7 9 17 11 13 18 19 16 23 20 24 21 25 22
perm
3 6 12 1 13 14 16 17 18 2 4 5 20 7 8 21 23 9 10 11 15 19 22 25 24
perm
1 3 2 5 7 9 4 6 8 11 20 10 12 22 23 13 14 24 15 16 17 25 18 19 21
poly
15 11
.........##
........###
........###
......#####
......#####
.....###...

output:

25 1000
poly
16 10
.........#
........##
......####
.....#####
....######
...#######
...#######
...######.
...######.
..####....
..####....
..###.....
..###.....
####......
###.......
##........
triang
1 2 6
1 6 7
1 7 8
1 8 11
1 11 13
1 13 14
1 14 18
1 18 19
1 19 25
1 25 27
2 3 4
2 4 5
2 5 6
8 9 11
...

result:

ok good communication process (1000 test cases)

Test #28:

score: 100
Accepted
time: 10ms
memory: 4040kb

input:

26 1000
triang
1 2 28
2 3 5
2 5 6
2 6 28
3 4 5
6 7 8
6 8 10
6 10 28
8 9 10
10 11 22
10 22 25
10 25 27
10 27 28
11 12 13
11 13 15
11 15 22
13 14 15
15 16 21
15 21 22
16 17 20
16 20 21
17 18 19
17 19 20
22 23 25
23 24 25
25 26 27
poly
14 13
..........###
.........####
......#######
......######.
....#...

output:

26 1000
perm
1 3 4 7 2 10 14 5 6 16 8 9 11 12 13 17 19 21 23 15 24 26 18 20 22 25 
triang
1 2 28
2 3 28
3 4 6
3 6 7
3 7 27
3 27 28
4 5 6
7 8 20
7 20 23
7 23 24
7 24 27
8 9 10
8 10 11
8 11 17
8 17 18
8 18 20
11 12 13
11 13 14
11 14 16
11 16 17
14 15 16
18 19 20
20 21 23
21 22 23
24 25 27
25 26 27
tri...

input:

26 1000
perm
1 3 4 7 2 10 14 5 6 16 8 9 11 12 13 17 19 21 23 15 24 26 18 20 22 25
triang
1 2 28
2 3 28
3 4 6
3 6 7
3 7 27
3 27 28
4 5 6
7 8 20
7 20 23
7 23 24
7 24 27
8 9 10
8 10 11
8 11 17
8 17 18
8 18 20
11 12 13
11 13 14
11 14 16
11 16 17
14 15 16
18 19 20
20 21 23
21 22 23
24 25 27
25 26 27
tria...

output:

26 1000
triang
1 2 28
2 3 5
2 5 6
2 6 28
3 4 5
6 7 8
6 8 10
6 10 28
8 9 10
10 11 22
10 22 25
10 25 27
10 27 28
11 12 13
11 13 15
11 15 22
13 14 15
15 16 21
15 21 22
16 17 20
16 20 21
17 18 19
17 19 20
22 23 25
23 24 25
25 26 27
poly
14 13
..........###
.........####
......#######
......######.
....#...

result:

ok good communication process (1000 test cases)

Test #29:

score: 100
Accepted
time: 10ms
memory: 4212kb

input:

27 1000
perm
2 4 7 1 10 14 15 3 5 6 8 9 11 18 20 23 24 12 25 13 16 17 19 21 27 22 26
poly
13 15
.............##
.............##
...........###.
...........###.
...........##..
.......######..
.......######..
.......####....
......#####....
..#########....
..#########....
.#######.......
#####..........

output:

27 1000
triang
1 2 3
1 3 5
1 5 9
1 9 29
3 4 5
5 6 7
5 7 9
7 8 9
9 10 13
9 13 28
9 28 29
10 11 12
10 12 13
13 14 15
13 15 24
13 24 25
13 25 26
13 26 28
15 16 17
15 17 24
17 18 24
18 19 20
18 20 21
18 21 24
21 22 23
21 23 24
26 27 28
triang
1 2 3
1 3 4
1 4 15
1 15 21
1 21 23
1 23 25
1 25 28
1 28 29
4 ...

input:

27 1000
triang
1 2 3
1 3 5
1 5 9
1 9 29
3 4 5
5 6 7
5 7 9
7 8 9
9 10 13
9 13 28
9 28 29
10 11 12
10 12 13
13 14 15
13 15 24
13 24 25
13 25 26
13 26 28
15 16 17
15 17 24
17 18 24
18 19 20
18 20 21
18 21 24
21 22 23
21 23 24
26 27 28
triang
1 2 3
1 3 4
1 4 15
1 15 21
1 21 23
1 23 25
1 25 28
1 28 29
4 ...

output:

27 1000
perm
2 4 7 1 10 14 15 3 5 6 8 9 11 18 20 23 24 12 25 13 16 17 19 21 27 22 26 
poly
13 15
.............##
.............##
...........###.
...........###.
...........##..
.......######..
.......######..
.......####....
......#####....
..#########....
..#########....
.#######.......
#####.........

result:

ok good communication process (1000 test cases)

Test #30:

score: 100
Accepted
time: 7ms
memory: 4260kb

input:

28 1000
poly
13 16
............####
........######..
......#######...
......#######...
....#########...
....#######.....
....#######.....
....#####.......
....##..........
..####..........
..###...........
.####...........
####............
triang
1 2 3
1 3 6
1 6 7
1 7 9
1 9 10
1 10 11
1 11 15
1 15 3...

output:

28 1000
perm
5 7 1 9 10 2 15 3 4 17 6 8 18 11 19 20 12 21 13 22 24 25 26 14 16 28 23 27 
perm
2 6 7 1 8 10 3 12 4 13 14 16 5 9 11 15 17 18 19 22 23 20 24 21 26 25 27 28 
perm
2 1 5 3 6 7 8 10 12 14 15 4 20 21 9 22 26 11 13 27 16 17 18 19 23 28 24 25 
perm
1 3 2 4 8 13 5 14 17 18 23 6 7 9 10 25 11 12...

input:

28 1000
perm
5 7 1 9 10 2 15 3 4 17 6 8 18 11 19 20 12 21 13 22 24 25 26 14 16 28 23 27
perm
2 6 7 1 8 10 3 12 4 13 14 16 5 9 11 15 17 18 19 22 23 20 24 21 26 25 27 28
perm
2 1 5 3 6 7 8 10 12 14 15 4 20 21 9 22 26 11 13 27 16 17 18 19 23 28 24 25
perm
1 3 2 4 8 13 5 14 17 18 23 6 7 9 10 25 11 12 15...

output:

28 1000
poly
13 16
............####
........######..
......#######...
......#######...
....#########...
....#######.....
....#######.....
....#####.......
....##..........
..####..........
..###...........
.####...........
####............
triang
1 2 3
1 3 6
1 6 7
1 7 9
1 9 10
1 10 11
1 11 15
1 15 3...

result:

ok good communication process (1000 test cases)

Test #31:

score: 100
Accepted
time: 11ms
memory: 4272kb

input:

29 1000
perm
1 4 2 3 5 6 8 13 7 9 18 20 10 23 11 12 14 15 16 17 19 21 24 26 22 27 28 25 29
poly
11 19
................###
.............####..
......########.....
.....########......
....########.......
..##########.......
..########.........
.#######...........
.######............
######...............

output:

29 1000
triang
1 2 31
2 3 4
2 4 16
2 16 20
2 20 31
4 5 6
4 6 7
4 7 16
7 8 14
7 14 15
7 15 16
8 9 14
9 10 11
9 11 12
9 12 13
9 13 14
16 17 19
16 19 20
17 18 19
20 21 31
21 22 24
21 24 25
21 25 27
21 27 30
21 30 31
22 23 24
25 26 27
27 28 30
28 29 30
perm
3 5 6 7 1 2 8 9 14 4 15 18 10 19 11 12 13 20 2...

input:

29 1000
triang
1 2 31
2 3 4
2 4 16
2 16 20
2 20 31
4 5 6
4 6 7
4 7 16
7 8 14
7 14 15
7 15 16
8 9 14
9 10 11
9 11 12
9 12 13
9 13 14
16 17 19
16 19 20
17 18 19
20 21 31
21 22 24
21 24 25
21 25 27
21 27 30
21 30 31
22 23 24
25 26 27
27 28 30
28 29 30
perm
3 5 6 7 1 2 8 9 14 4 15 18 10 19 11 12 13 20 2...

output:

29 1000
perm
1 4 2 3 5 6 8 13 7 9 18 20 10 23 11 12 14 15 16 17 19 21 24 26 22 27 28 25 29 
poly
11 19
................###
.............####..
......########.....
.....########......
....########.......
..##########.......
..########.........
.#######...........
.######............
######..............

result:

ok good communication process (1000 test cases)

Test #32:

score: 100
Accepted
time: 12ms
memory: 4060kb

input:

30 1000
perm
3 5 6 10 11 12 1 2 14 4 7 16 8 19 24 9 13 15 25 26 17 18 27 28 29 20 21 22 30 23
poly
11 20
................####
...............##...
........#########...
........#######.....
.......######.......
.....#######........
.....#####..........
.....####...........
.....##.............
.#####...

output:

30 1000
triang
1 2 19
1 19 27
1 27 28
1 28 29
1 29 32
2 3 4
2 4 7
2 7 9
2 9 19
4 5 6
4 6 7
7 8 9
9 10 13
9 13 19
10 11 12
10 12 13
13 14 15
13 15 16
13 16 18
13 18 19
16 17 18
19 20 27
20 21 27
21 22 27
22 23 27
23 24 26
23 26 27
24 25 26
29 30 31
29 31 32
triang
1 2 3
1 3 4
1 4 6
1 6 8
1 8 12
1 12 ...

input:

30 1000
triang
1 2 19
1 19 27
1 27 28
1 28 29
1 29 32
2 3 4
2 4 7
2 7 9
2 9 19
4 5 6
4 6 7
7 8 9
9 10 13
9 13 19
10 11 12
10 12 13
13 14 15
13 15 16
13 16 18
13 18 19
16 17 18
19 20 27
20 21 27
21 22 27
22 23 27
23 24 26
23 26 27
24 25 26
29 30 31
29 31 32
triang
1 2 3
1 3 4
1 4 6
1 6 8
1 8 12
1 12 ...

output:

30 1000
perm
3 5 6 10 11 12 1 2 14 4 7 16 8 19 24 9 13 15 25 26 17 18 27 28 29 20 21 22 30 23 
poly
11 20
................####
...............##...
........#########...
........#######.....
.......######.......
.....#######........
.....#####..........
.....####...........
.....##.............
.####...

result:

ok good communication process (1000 test cases)

Test #33:

score: 100
Accepted
time: 13ms
memory: 4088kb

input:

32 1000
perm
1 6 2 7 3 4 8 11 12 13 15 16 19 20 21 5 23 9 10 24 14 25 26 28 30 17 31 32 18 22 27 29
triang
1 2 29
1 29 34
2 3 13
2 13 14
2 14 15
2 15 18
2 18 19
2 19 22
2 22 24
2 24 29
3 4 13
4 5 10
4 10 11
4 11 12
4 12 13
5 6 7
5 7 9
5 9 10
7 8 9
15 16 17
15 17 18
19 20 22
20 21 22
22 23 24
24 25 2...

output:

32 1000
poly
18 15
..............#
............###
...........####
...........####
..........#####
..........####.
.......######..
.......######..
.......#####...
.......####....
.....#####.....
..#######......
..#######......
.#######.......
.#######.......
.######........
#####..........
#...........

input:

32 1000
poly
18 15
..............#
............###
...........####
...........####
..........#####
..........####.
.......######..
.......######..
.......#####...
.......####....
.....#####.....
..#######......
..#######......
.#######.......
.#######.......
.######........
#####..........
#...........

output:

32 1000
perm
1 6 2 7 3 4 8 11 12 13 15 16 19 20 21 5 23 9 10 24 14 25 26 28 30 17 31 32 18 22 27 29 
triang
1 2 29
1 29 34
2 3 13
2 13 14
2 14 15
2 15 18
2 18 19
2 19 22
2 22 24
2 24 29
3 4 13
4 5 10
4 10 11
4 11 12
4 12 13
5 6 7
5 7 9
5 9 10
7 8 9
15 16 17
15 17 18
19 20 22
20 21 22
22 23 24
24 25 ...

result:

ok good communication process (1000 test cases)

Test #34:

score: 100
Accepted
time: 13ms
memory: 4316kb

input:

33 1000
triang
1 2 28
1 28 35
2 3 28
3 4 5
3 5 23
3 23 24
3 24 28
5 6 7
5 7 23
7 8 16
7 16 19
7 19 20
7 20 23
8 9 10
8 10 15
8 15 16
10 11 13
10 13 15
11 12 13
13 14 15
16 17 18
16 18 19
20 21 22
20 22 23
24 25 26
24 26 28
26 27 28
28 29 31
28 31 35
29 30 31
31 32 33
31 33 35
33 34 35
perm
2 3 5 6 7...

output:

33 1000
perm
3 1 5 7 8 9 2 4 6 10 14 16 11 12 13 18 15 17 19 22 23 24 26 20 21 31 25 27 28 29 32 30 33 
poly
16 18
................##
..............####
..........########
..........####....
........#####.....
........####......
........####......
......######......
......#####.......
....#######......

input:

33 1000
perm
3 1 5 7 8 9 2 4 6 10 14 16 11 12 13 18 15 17 19 22 23 24 26 20 21 31 25 27 28 29 32 30 33
poly
16 18
................##
..............####
..........########
..........####....
........#####.....
........####......
........####......
......######......
......#####.......
....#######.......

output:

33 1000
triang
1 2 28
1 28 35
2 3 28
3 4 5
3 5 23
3 23 24
3 24 28
5 6 7
5 7 23
7 8 16
7 16 19
7 19 20
7 20 23
8 9 10
8 10 15
8 15 16
10 11 13
10 13 15
11 12 13
13 14 15
16 17 18
16 18 19
20 21 22
20 22 23
24 25 26
24 26 28
26 27 28
28 29 31
28 31 35
29 30 31
31 32 33
31 33 35
33 34 35
perm
2 3 5 6 7...

result:

ok good communication process (1000 test cases)

Test #35:

score: 100
Accepted
time: 14ms
memory: 4128kb

input:

34 1000
triang
1 2 36
2 3 36
3 4 34
3 34 36
4 5 6
4 6 32
4 32 33
4 33 34
6 7 8
6 8 10
6 10 11
6 11 12
6 12 13
6 13 32
8 9 10
13 14 18
13 18 32
14 15 18
15 16 18
16 17 18
18 19 20
18 20 22
18 22 23
18 23 32
20 21 22
23 24 32
24 25 32
25 26 31
25 31 32
26 27 29
26 29 30
26 30 31
27 28 29
34 35 36
poly...

output:

34 1000
perm
1 2 5 8 9 10 3 4 6 7 13 11 15 20 21 23 12 14 16 17 18 24 19 22 29 25 31 32 33 26 27 34 28 30 
triang
1 2 36
2 3 4
2 4 36
4 5 35
4 35 36
5 6 35
6 7 8
6 8 32
6 32 35
8 9 15
8 15 32
9 10 11
9 11 13
9 13 15
11 12 13
13 14 15
15 16 32
16 17 18
16 18 21
16 21 23
16 23 30
16 30 31
16 31 32
18 ...

input:

34 1000
perm
1 2 5 8 9 10 3 4 6 7 13 11 15 20 21 23 12 14 16 17 18 24 19 22 29 25 31 32 33 26 27 34 28 30
triang
1 2 36
2 3 4
2 4 36
4 5 35
4 35 36
5 6 35
6 7 8
6 8 32
6 32 35
8 9 15
8 15 32
9 10 11
9 11 13
9 13 15
11 12 13
13 14 15
15 16 32
16 17 18
16 18 21
16 21 23
16 23 30
16 30 31
16 31 32
18 1...

output:

34 1000
triang
1 2 36
2 3 36
3 4 34
3 34 36
4 5 6
4 6 32
4 32 33
4 33 34
6 7 8
6 8 10
6 10 11
6 11 12
6 12 13
6 13 32
8 9 10
13 14 18
13 18 32
14 15 18
15 16 18
16 17 18
18 19 20
18 20 22
18 22 23
18 23 32
20 21 22
23 24 32
24 25 32
25 26 31
25 31 32
26 27 29
26 29 30
26 30 31
27 28 29
34 35 36
poly...

result:

ok good communication process (1000 test cases)

Test #36:

score: 100
Accepted
time: 9ms
memory: 4152kb

input:

35 1000
poly
19 17
.............####
..........#######
..........######.
..........####...
..........####...
.........#####...
.........#####...
.........#####...
.........#####...
........####.....
........####.....
........##.......
......####.......
.#########.......
##...............
#.............

output:

35 1000
triang
1 2 37
2 3 37
3 4 37
4 5 37
5 6 36
5 36 37
6 7 13
6 13 19
6 19 21
6 21 29
6 29 31
6 31 32
6 32 33
6 33 34
6 34 35
6 35 36
7 8 11
7 11 12
7 12 13
8 9 11
9 10 11
13 14 16
13 16 17
13 17 19
14 15 16
17 18 19
19 20 21
21 22 29
22 23 29
23 24 27
23 27 29
24 25 27
25 26 27
27 28 29
29 30 31...

input:

35 1000
triang
1 2 37
2 3 37
3 4 37
4 5 37
5 6 36
5 36 37
6 7 13
6 13 19
6 19 21
6 21 29
6 29 31
6 31 32
6 32 33
6 33 34
6 34 35
6 35 36
7 8 11
7 11 12
7 12 13
8 9 11
9 10 11
13 14 16
13 16 17
13 17 19
14 15 16
17 18 19
19 20 21
21 22 29
22 23 29
23 24 27
23 27 29
24 25 27
25 26 27
27 28 29
29 30 31...

output:

35 1000
poly
19 17
.............####
..........#######
..........######.
..........####...
..........####...
.........#####...
.........#####...
.........#####...
.........#####...
........####.....
........####.....
........##.......
......####.......
.#########.......
##...............
#.............

result:

ok good communication process (1000 test cases)

Test #37:

score: 100
Accepted
time: 14ms
memory: 4348kb

input:

35 1000
triang
1 2 6
1 6 9
1 9 31
1 31 37
2 3 6
3 4 6
4 5 6
6 7 8
6 8 9
9 10 12
9 12 31
10 11 12
12 13 14
12 14 30
12 30 31
14 15 17
14 17 18
14 18 23
14 23 30
15 16 17
18 19 22
18 22 23
19 20 21
19 21 22
23 24 26
23 26 27
23 27 30
24 25 26
27 28 29
27 29 30
31 32 33
31 33 34
31 34 35
31 35 36
31 36...

output:

35 1000
poly
20 16
..............##
...........####.
...........####.
...........####.
...........####.
..........#####.
........#######.
.......########.
......#########.
.....##########.
.....##########.
.....#########..
.....#########..
....##########..
...###########..
...###..........
...##.......

input:

35 1000
poly
20 16
..............##
...........####.
...........####.
...........####.
...........####.
..........#####.
........#######.
.......########.
......#########.
.....##########.
.....##########.
.....#########..
.....#########..
....##########..
...###########..
...###..........
...##.......

output:

35 1000
triang
1 2 6
1 6 9
1 9 31
1 31 37
2 3 6
3 4 6
4 5 6
6 7 8
6 8 9
9 10 12
9 12 31
10 11 12
12 13 14
12 14 30
12 30 31
14 15 17
14 17 18
14 18 23
14 23 30
15 16 17
18 19 22
18 22 23
19 20 21
19 21 22
23 24 26
23 26 27
23 27 30
24 25 26
27 28 29
27 29 30
31 32 33
31 33 34
31 34 35
31 35 36
31 36...

result:

ok good communication process (1000 test cases)

Test #38:

score: 100
Accepted
time: 15ms
memory: 4172kb

input:

35 1000
perm
1 2 6 3 4 10 11 5 7 13 16 8 9 12 17 14 15 21 22 24 18 19 27 20 23 31 25 26 32 35 28 29 30 33 34
triang
1 2 4
1 4 31
1 31 32
1 32 35
1 35 37
2 3 4
4 5 6
4 6 7
4 7 8
4 8 31
8 9 31
9 10 30
9 30 31
10 11 30
11 12 15
11 15 16
11 16 17
11 17 28
11 28 29
11 29 30
12 13 15
13 14 15
17 18 19
17 ...

output:

35 1000
poly
16 20
..................##
.................###
............#######.
............####....
...........####.....
........#######.....
.......######.......
......#######.......
......#####.........
......####..........
....######..........
...#####............
########............
#####......

input:

35 1000
poly
16 20
..................##
.................###
............#######.
............####....
...........####.....
........#######.....
.......######.......
......#######.......
......#####.........
......####..........
....######..........
...#####............
########............
#####......

output:

35 1000
perm
1 2 6 3 4 10 11 5 7 13 16 8 9 12 17 14 15 21 22 24 18 19 27 20 23 31 25 26 32 35 28 29 30 33 34 
triang
1 2 4
1 4 31
1 31 32
1 32 35
1 35 37
2 3 4
4 5 6
4 6 7
4 7 8
4 8 31
8 9 31
9 10 30
9 30 31
10 11 30
11 12 15
11 15 16
11 16 17
11 17 28
11 28 29
11 29 30
12 13 15
13 14 15
17 18 19
17...

result:

ok good communication process (1000 test cases)

Test #39:

score: 100
Accepted
time: 14ms
memory: 4120kb

input:

35 1000
triang
1 2 33
1 33 34
1 34 37
2 3 29
2 29 30
2 30 33
3 4 11
3 11 29
4 5 6
4 6 7
4 7 9
4 9 11
7 8 9
9 10 11
11 12 13
11 13 29
13 14 15
13 15 18
13 18 29
15 16 17
15 17 18
18 19 20
18 20 27
18 27 28
18 28 29
20 21 22
20 22 23
20 23 25
20 25 26
20 26 27
23 24 25
30 31 32
30 32 33
34 35 36
34 36...

output:

35 1000
perm
3 5 7 1 8 12 2 13 14 15 20 4 6 21 25 26 28 29 9 10 30 11 16 32 17 18 34 35 19 22 23 24 27 31 33 
poly
17 19
...............####
...............###.
............######.
.......#########...
.......#######.....
.......#######.....
.......######......
......#######......
.....#######..........

input:

35 1000
perm
3 5 7 1 8 12 2 13 14 15 20 4 6 21 25 26 28 29 9 10 30 11 16 32 17 18 34 35 19 22 23 24 27 31 33
poly
17 19
...............####
...............###.
............######.
.......#########...
.......#######.....
.......#######.....
.......######......
......#######......
.....#######.......
...

output:

35 1000
triang
1 2 33
1 33 34
1 34 37
2 3 29
2 29 30
2 30 33
3 4 11
3 11 29
4 5 6
4 6 7
4 7 9
4 9 11
7 8 9
9 10 11
11 12 13
11 13 29
13 14 15
13 15 18
13 18 29
15 16 17
15 17 18
18 19 20
18 20 27
18 27 28
18 28 29
20 21 22
20 22 23
20 23 25
20 25 26
20 26 27
23 24 25
30 31 32
30 32 33
34 35 36
34 36...

result:

ok good communication process (1000 test cases)

Test #40:

score: 100
Accepted
time: 14ms
memory: 4140kb

input:

35 1000
poly
18 18
................##
...............###
...............#..
...............#..
..............##..
............###...
...........####...
.........####.....
......######......
......#####.......
..#########.......
..#########.......
.#######..........
.#####............
######............

output:

35 1000
perm
1 3 8 10 13 14 15 18 2 4 21 22 5 6 23 7 24 9 11 25 12 16 26 17 19 28 20 31 33 27 29 34 35 30 32 
poly
21 15
..............#
..........#####
.........#####.
.......#######.
.......#######.
.......#######.
......#######..
......######...
......######...
......######...
......####.....
......

input:

35 1000
perm
1 3 8 10 13 14 15 18 2 4 21 22 5 6 23 7 24 9 11 25 12 16 26 17 19 28 20 31 33 27 29 34 35 30 32
poly
21 15
..............#
..........#####
.........#####.
.......#######.
.......#######.
.......#######.
......#######..
......######...
......######...
......######...
......####.....
.......

output:

35 1000
poly
18 18
................##
...............###
...............#..
...............#..
..............##..
............###...
...........####...
.........####.....
......######......
......#####.......
..#########.......
..#########.......
.#######..........
.#####............
######............

result:

ok good communication process (1000 test cases)

Test #41:

score: 100
Accepted
time: 10ms
memory: 4152kb

input:

35 1000
poly
19 17
................#
................#
................#
...............##
..............###
............#####
............#####
............###..
...........###...
.....#########...
....#######......
....#######......
....#####........
...#####.........
..######.........
..#####.......

output:

35 1000
perm
5 6 7 8 1 2 9 3 18 4 22 10 11 23 24 12 13 25 27 14 15 16 29 17 19 30 20 31 21 26 33 34 35 28 32 
perm
2 3 9 11 1 4 13 5 6 7 14 15 17 20 21 8 22 10 23 12 24 16 26 18 28 31 19 25 33 27 29 34 30 35 32 
poly
17 19
...............####
...............###.
..............####.
..............###...

input:

35 1000
perm
5 6 7 8 1 2 9 3 18 4 22 10 11 23 24 12 13 25 27 14 15 16 29 17 19 30 20 31 21 26 33 34 35 28 32
perm
2 3 9 11 1 4 13 5 6 7 14 15 17 20 21 8 22 10 23 12 24 16 26 18 28 31 19 25 33 27 29 34 30 35 32
poly
17 19
...............####
...............###.
..............####.
..............####....

output:

35 1000
poly
19 17
................#
................#
................#
...............##
..............###
............#####
............#####
............###..
...........###...
.....#########...
....#######......
....#######......
....#####........
...#####.........
..######.........
..#####.......

result:

ok good communication process (1000 test cases)

Test #42:

score: 100
Accepted
time: 14ms
memory: 4124kb

input:

35 1000
poly
12 24
...............#########
...........#############
...........##########...
...........######.......
..........#######.......
.........#######........
........#######.........
.......#######..........
....########............
...########.............
..#######...............
######...

output:

35 1000
perm
8 1 2 3 9 10 13 4 14 15 16 5 19 6 7 11 21 12 22 24 25 26 29 17 18 30 31 20 23 27 32 34 35 28 33 
triang
1 2 3
1 3 37
3 4 35
3 35 37
4 5 35
5 6 7
5 7 8
5 8 35
8 9 35
9 10 29
9 29 32
9 32 34
9 34 35
10 11 12
10 12 20
10 20 29
12 13 20
13 14 20
14 15 20
15 16 20
16 17 20
17 18 19
17 19 20
...

input:

35 1000
perm
8 1 2 3 9 10 13 4 14 15 16 5 19 6 7 11 21 12 22 24 25 26 29 17 18 30 31 20 23 27 32 34 35 28 33
triang
1 2 3
1 3 37
3 4 35
3 35 37
4 5 35
5 6 7
5 7 8
5 8 35
8 9 35
9 10 29
9 29 32
9 32 34
9 34 35
10 11 12
10 12 20
10 20 29
12 13 20
13 14 20
14 15 20
15 16 20
16 17 20
17 18 19
17 19 20
2...

output:

35 1000
poly
12 24
...............#########
...........#############
...........##########...
...........######.......
..........#######.......
.........#######........
........#######.........
.......#######..........
....########............
...########.............
..#######...............
######...

result:

ok good communication process (1000 test cases)

Test #43:

score: 100
Accepted
time: 11ms
memory: 4112kb

input:

35 1000
triang
1 2 13
1 13 36
1 36 37
2 3 13
3 4 9
3 9 12
3 12 13
4 5 6
4 6 9
6 7 9
7 8 9
9 10 11
9 11 12
13 14 36
14 15 16
14 16 29
14 29 36
16 17 18
16 18 29
18 19 29
19 20 22
19 22 28
19 28 29
20 21 22
22 23 27
22 27 28
23 24 27
24 25 27
25 26 27
29 30 33
29 33 36
30 31 33
31 32 33
33 34 35
33 35...

output:

35 1000
perm
5 1 6 10 13 14 2 3 16 4 7 8 9 17 11 19 20 21 12 25 15 18 27 22 28 23 29 24 30 31 33 26 34 32 35 
perm
7 1 2 3 8 13 17 4 5 6 18 20 22 24 9 25 10 11 12 14 26 27 28 15 16 29 19 21 32 23 30 31 34 33 35 
poly
16 20
................####
...............#####
.............#####..
.............#...

input:

35 1000
perm
5 1 6 10 13 14 2 3 16 4 7 8 9 17 11 19 20 21 12 25 15 18 27 22 28 23 29 24 30 31 33 26 34 32 35
perm
7 1 2 3 8 13 17 4 5 6 18 20 22 24 9 25 10 11 12 14 26 27 28 15 16 29 19 21 32 23 30 31 34 33 35
poly
16 20
................####
...............#####
.............#####..
.............###...

output:

35 1000
triang
1 2 13
1 13 36
1 36 37
2 3 13
3 4 9
3 9 12
3 12 13
4 5 6
4 6 9
6 7 9
7 8 9
9 10 11
9 11 12
13 14 36
14 15 16
14 16 29
14 29 36
16 17 18
16 18 29
18 19 29
19 20 22
19 22 28
19 28 29
20 21 22
22 23 27
22 27 28
23 24 27
24 25 27
25 26 27
29 30 33
29 33 36
30 31 33
31 32 33
33 34 35
33 35...

result:

ok good communication process (1000 test cases)

Test #44:

score: 100
Accepted
time: 14ms
memory: 4112kb

input:

35 1000
poly
16 20
.................###
.................###
................###.
..............####..
.........########...
.........########...
.....############...
.....############...
.....###########....
.....#########......
...##########.......
...#########........
...######...........
.######....

output:

35 1000
triang
1 2 4
1 4 5
1 5 36
1 36 37
2 3 4
5 6 36
6 7 8
6 8 9
6 9 36
9 10 12
9 12 18
9 18 26
9 26 27
9 27 30
9 30 32
9 32 36
10 11 12
12 13 14
12 14 17
12 17 18
14 15 16
14 16 17
18 19 21
18 21 26
19 20 21
21 22 26
22 23 24
22 24 25
22 25 26
27 28 30
28 29 30
30 31 32
32 33 34
32 34 36
34 35 36...

input:

35 1000
triang
1 2 4
1 4 5
1 5 36
1 36 37
2 3 4
5 6 36
6 7 8
6 8 9
6 9 36
9 10 12
9 12 18
9 18 26
9 26 27
9 27 30
9 30 32
9 32 36
10 11 12
12 13 14
12 14 17
12 17 18
14 15 16
14 16 17
18 19 21
18 21 26
19 20 21
21 22 26
22 23 24
22 24 25
22 25 26
27 28 30
28 29 30
30 31 32
32 33 34
32 34 36
34 35 36...

output:

35 1000
poly
16 20
.................###
.................###
................###.
..............####..
.........########...
.........########...
.....############...
.....############...
.....###########....
.....#########......
...##########.......
...#########........
...######...........
.######....

result:

ok good communication process (1000 test cases)

Test #45:

score: 100
Accepted
time: 15ms
memory: 4140kb

input:

35 1000
perm
3 1 4 5 8 9 2 11 6 15 17 20 7 22 10 23 25 12 28 13 31 33 14 16 18 34 19 35 21 24 26 27 29 30 32
perm
4 1 7 2 3 8 5 13 18 19 20 6 9 21 24 10 26 28 11 12 14 29 31 15 32 33 16 17 34 22 23 25 35 27 30
poly
18 18
.................#
...............###
............######
............######
......

output:

35 1000
triang
1 2 6
1 6 7
1 7 27
1 27 37
2 3 6
3 4 5
3 5 6
7 8 27
8 9 27
9 10 11
9 11 14
9 14 27
11 12 14
12 13 14
14 15 22
14 22 27
15 16 22
16 17 22
17 18 22
18 19 22
19 20 21
19 21 22
22 23 25
22 25 27
23 24 25
25 26 27
27 28 37
28 29 30
28 30 32
28 32 37
30 31 32
32 33 36
32 36 37
33 34 36
34 3...

input:

35 1000
triang
1 2 6
1 6 7
1 7 27
1 27 37
2 3 6
3 4 5
3 5 6
7 8 27
8 9 27
9 10 11
9 11 14
9 14 27
11 12 14
12 13 14
14 15 22
14 22 27
15 16 22
16 17 22
17 18 22
18 19 22
19 20 21
19 21 22
22 23 25
22 25 27
23 24 25
25 26 27
27 28 37
28 29 30
28 30 32
28 32 37
30 31 32
32 33 36
32 36 37
33 34 36
34 3...

output:

35 1000
perm
3 1 4 5 8 9 2 11 6 15 17 20 7 22 10 23 25 12 28 13 31 33 14 16 18 34 19 35 21 24 26 27 29 30 32 
perm
4 1 7 2 3 8 5 13 18 19 20 6 9 21 24 10 26 28 11 12 14 29 31 15 32 33 16 17 34 22 23 25 35 27 30 
poly
18 18
.................#
...............###
............######
............######
....

result:

ok good communication process (1000 test cases)