QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#23045#2894. 麻将模拟器mahjongAC ✓233ms89680kbC++146.6kb2022-03-11 17:10:062022-04-30 02:15:53

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 02:15:53]
  • 评测
  • 测评结果:AC
  • 用时:233ms
  • 内存:89680kb
  • [2022-03-11 17:10:06]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int now,dir=1;
int nowpaidui,DP[2000005][5][2],pw[12];
int CNT[2000005];
inline void init()
{
	pw[0]=1;
	for(int i=1;i<=10;i++) pw[i]=pw[i-1]*5;
	for(int i=0;i<=2000000;i++)
	{
		for(int j=0;j<=4;j++) DP[i][j][0]=DP[i][j][1]=1e9;
		int x=i;
		while(x) CNT[i]+=x%5,x/=5;
	}
	DP[0][0][0]=0;
	for(int i=0;i<=2000000;i++)
	{
		for(int x=0;x<=4;x++)
		{
			for(int y=0;y<=1;y++)
			{
				if(DP[i][x][y]) continue;
				if(!y) for(int k=0;k<=8;k++)
				{
					int X=(i/pw[k])%5,qwq=(pw[k]);
					if(X<=2) DP[i+qwq*2][x][y+1]=min(DP[i+qwq*2][x][y+1],DP[i][x][y]);
				}
				if(x<4)
				{
					for(int k=0;k<=8;k++)
					{
						int X=(i/pw[k])%5,qwq=(pw[k]);
						if(X<=1) DP[i+qwq*3][x+1][y]=min(DP[i+qwq*3][x+1][y],DP[i][x][y]);
					}
					for(int k=0;k<=6;k++)
					{
						int X=(i/pw[k])%5,Y=(i/pw[k+1])%5,Z=(i/pw[k+2])%5,qwq=(pw[k]);
						if(X<=3&&Y<=3&&Z<=3) DP[i+qwq*31][x+1][y]=min(DP[i+qwq*31][x+1][y],DP[i][x][y]);
					}
				}
			}
		}
	}
	for(int i=0;i<=2000000;i++)
	{
		if(CNT[i]>14) continue;
		for(int x=0;x<=4;x++)
		{
			for(int y=0;y<=1;y++)
			{
				for(int k=0;k<=8;k++)
				{
					int X=(i/pw[k])%5,qwq=(pw[k]);
					if(X>=1) DP[i][x][y]=min(DP[i-qwq][x][y],DP[i][x][y]);
				}
			}
		}
	}
	for(int i=2000000;i>=0;i--)
	{
		if(CNT[i]>14) continue;
		for(int x=0;x<=4;x++)
		{
			for(int y=0;y<=1;y++)
			{
				for(int k=0;k<=8;k++)
				{
					int X=(i/pw[k])%5,qwq=(pw[k]);
					if(X>=1) DP[i-qwq][x][y]=min(DP[i-qwq][x][y],DP[i][x][y]+1);
				}
			}
		}
	}
}
string paidui[200];
inline int trans(string s)
{
	if(s=="PASS") return 42;
	if(s=="REVERSE") return 44;
	if(s=="DOUBLE") return 46;
	if(s=="E") return 31;
	if(s=="S") return 32;
	if(s=="W") return 33;
	if(s=="N") return 34;
	if(s=="B") return 35;
	if(s=="F") return 36;
	if(s=="Z") return 37;
	if(s[1]=='M') return s[0]-'0';
	if(s[1]=='P') return s[0]-'0'+10;
	return s[0]-'0'+20;
}
inline string TRANS(int s)
{
	if(s==42) return "PASS";
	if(s==44) return "REVERSE";
	if(s==46) return "DOUBLE";
	if(s==31) return "E";
	if(s==32) return "S";
	if(s==33) return "W";
	if(s==34) return "N";
	if(s==35) return "B";
	if(s==36) return "F";
	if(s==37) return "Z";
	string rtn;
	rtn+=(char)(s%10+'0');
	if(s<=10) rtn+='M';
	else if(s<=20) rtn+='P';
	else rtn+='S';
	return rtn;
}
struct pai
{
	int cnt[50]={},fulu=0;
	string name;
	inline int dist()
	{
		int dp[5][2];
		for(int i=0;i<=4;i++) dp[i][0]=dp[i][1]=1e9;
		dp[0][0]=0;
		int qwq=0;
		for(int i=1;i<=9;i++) qwq*=5,qwq+=cnt[i];
		for(int i=4;i>=0;i--)
			for(int j=1;j>=0;j--)
				for(int k=0;k+i<=4;k++)
					for(int l=0;l+j<=1;l++)
						dp[i+k][j+l]=min(dp[i+k][j+l],dp[i][j]+DP[qwq][k][l]);
		qwq=0;
		for(int i=11;i<=19;i++) qwq*=5,qwq+=cnt[i];
		for(int i=4;i>=0;i--)
			for(int j=1;j>=0;j--)
				for(int k=0;k+i<=4;k++)
					for(int l=0;l+j<=1;l++)
						dp[i+k][j+l]=min(dp[i+k][j+l],dp[i][j]+DP[qwq][k][l]);
		qwq=0;
		for(int i=21;i<=29;i++) qwq*=5,qwq+=cnt[i];
		for(int i=4;i>=0;i--)
			for(int j=1;j>=0;j--)
				for(int k=0;k+i<=4;k++)
					for(int l=0;l+j<=1;l++)
						dp[i+k][j+l]=min(dp[i+k][j+l],dp[i][j]+DP[qwq][k][l]);
		for(int x=31;x<=37;x++)
		{
			for(int i=4;i>=0;i--) for(int j=1;j>=0;j--)
			{
				if(i!=4) dp[i+1][j]=min(dp[i+1][j],dp[i][j]+3-min(3,cnt[x]));
				if(j!=1) dp[i][j+1]=min(dp[i][j+1],dp[i][j]+2-min(2,cnt[x]));
			}
		}
		return dp[4-fulu][1];
	}
	inline void zimo()
	{
		if(dist()==0)
		{
			cout << name << " " << "SELFDRAWN\n";
			cout << name << " " << "WIN\n"; 
			exit(0);
		}
	}
	inline void mopai()
	{
		if(nowpaidui==148)
		{
			cout << "DRAW";
			exit(0);
		}
		cout << name+" IN " << paidui[++nowpaidui] << "\n";
		++cnt[trans(paidui[nowpaidui])];
		zimo();
	}
	inline int chupai()
	{
		if(cnt[42])
		{
			--cnt[42];
			now=(now+dir)%4;
			now=(now+dir)%4;
			return 42;
		}
		if(cnt[44])
		{
			--cnt[44];
			dir=4-dir;
			now=(now+dir)%4;
			return 44;
		}
		if(cnt[46])
		{
			--cnt[46];
			return 46;
		}
		now=(now+dir)%4;
		int mn=1e9,pos=42;
		for(int i=40;i>=0;i--) 
		{
			if(cnt[i])
			{
				--cnt[i];
				int x=dist();
				++cnt[i];
				if(x<mn) mn=x,pos=i;
			//	if(name=="C") cout << name << " " << x << "qwqwqwqwqwqwqwq" << pos << "\n"; 
			}
		}
		--cnt[pos];
		return pos;
	}
	inline bool chow(int x)
	{
		if(x>=30) return 0;
		int lst=dist();
		if(cnt[x+1]&&cnt[x+2])
		{
			--cnt[x+1],--cnt[x+2],++fulu;
			if(dist()<lst)
			{
				cout << name << " CHOW " << TRANS(x)+" "+TRANS(x+1)+" "+TRANS(x+2)+"\n";
				return 1; 
			}
			++cnt[x+1],++cnt[x+2],--fulu;
		}
		if(cnt[x+1]&&cnt[x-1])
		{
			--cnt[x+1],--cnt[x-1],++fulu;
			if(dist()<lst)
			{
				cout << name << " CHOW " << TRANS(x-1)+" "+TRANS(x)+" "+TRANS(x+1)+"\n";
				return 1; 
			}
			++cnt[x+1],++cnt[x-1],--fulu;
		}
		if(cnt[x-2]&&cnt[x-1])
		{
			--cnt[x-2],--cnt[x-1],++fulu;
			if(dist()<lst)
			{
				cout << name << " CHOW " << TRANS(x-2)+" "+TRANS(x-1)+" "+TRANS(x)+"\n";
				return 1; 
			}
			++cnt[x-2],++cnt[x-1],--fulu;
		}
		return 0;
	}
	inline void print()
	{
		for(int i=1;i<=48;i++)
		{
			for(int j=1;j<=cnt[i];j++)
				cout << TRANS(i) << " ";
		}
		cout << "\n";
	}
}a[4];
inline int pong(int x)
{
	if(x>38) return -1;
	for(int i=0;i<4;i++)
	{
		if(a[i].cnt[x]>=2)
		{
			int lst=a[i].dist();
			a[i].cnt[x]-=2;
			++a[i].fulu;
			if(a[i].dist()>=lst)
			{
				--a[i].fulu;
				a[i].cnt[x]+=2;
			}
			else
			{
				cout << a[i].name << " PONG " << TRANS(x)+" "+TRANS(x)+" "+TRANS(x)+"\n";
				now=i;
				return i;
			}
		}
	}
	return -1;
}
inline void ron(int x,int i)
{
	for(int I=0;I<4;I++)
	{
		++a[i].cnt[x];
		if(a[i].dist()==0)
		{
			cout << a[i].name << " " << "RON\n";
			cout << a[i].name << " " << "WIN\n"; 
			exit(0);
		}
		--a[i].cnt[x];
		i=(i+dir)%4;
	}
}
signed main()
{
	a[0].name="A";
	a[1].name="B";
	a[2].name="C";
	a[3].name="D";
	init();
	for(int i=1;i<=148;i++)
		cin >> paidui[i];
	now=0,dir=1;
	for(int i=1;i<=52;i++)
	{
		a[now].mopai();
		now=(now+dir)%4;
	}
//	a[0].print();
//	cout << a[2].dist() << "**************************";
//	cout << DP[pw[2]+pw[3]+pw[4]+pw[6]+pw[8]][1][0] << "\n"; 
	int flag=1;
	while(1)
	{
		if(flag) a[now].mopai();
		flag=1;
		int lst=now,x=a[now].chupai();
	//	--a[lst].cnt[x];
		cout << a[lst].name << " OUT " << TRANS(x);
		if(TRANS(x)=="PASS") cout << " " << a[(lst+dir)%4].name;
		cout << "\n";
		ron(x,lst);
		int nx=pong(x);
		if(nx!=-1) now=nx,flag=0;
		else if(a[now].chow(x)) flag=0;
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 201ms
memory: 89680kb

input:

8M
Z
E
9P
3P
9S
5P
W
3M
8P
DOUBLE
5P
Z
2P
3M
8S
2S
5P
5M
E
6M
9S
6P
5S
7M
4S
3S
6M
3S
2M
9M
5S
Z
7P
5P
8M
3M
F
7M
2S
N
4P
3S
S
PASS
1P
6S
3P
9P
9S
4M
8P
N
Z
N
5M
DOUBLE
REVERSE
S
3P
4M
4S
1S
PASS
4P
6S
7S
7P
6S
9M
REVERSE
3P
7P
DOUBLE
B
9P
4S
5S
7S
7S
7P
6S
9S
B
9M
S
F
2P
1P
PASS
9P
DOUBLE
4P
PASS
5...

output:

A IN 8M
B IN Z
C IN E
D IN 9P
A IN 3P
B IN 9S
C IN 5P
D IN W
A IN 3M
B IN 8P
C IN DOUBLE
D IN 5P
A IN Z
B IN 2P
C IN 3M
D IN 8S
A IN 2S
B IN 5P
C IN 5M
D IN E
A IN 6M
B IN 9S
C IN 6P
D IN 5S
A IN 7M
B IN 4S
C IN 3S
D IN 6M
A IN 3S
B IN 2M
C IN 9M
D IN 5S
A IN Z
B IN 7P
C IN 5P
D IN 8M
A IN 3M
B IN F...

result:

ok 84 lines

Test #2:

score: 0
Accepted
time: 200ms
memory: 89604kb

input:

REVERSE
4S
8S
6P
4P
F
1P
W
9P
N
9M
B
7S
5P
PASS
5M
7M
9S
1S
2P
3S
6S
B
2S
9P
9M
4S
3M
W
6P
8P
W
2M
7P
6M
8M
2S
S
F
W
DOUBLE
E
2P
E
2M
8S
2S
9P
1M
7S
8M
N
4P
1S
1P
S
3P
3S
B
3M
7P
5S
3M
5M
7M
2S
E
9P
1M
7P
3P
5P
REVERSE
5S
9S
8M
4M
7P
1S
7M
1M
1M
8P
9S
6M
7S
PASS
4M
3M
9M
B
2P
4P
6S
F
4S
6P
6P
7M
1S
...

output:

A IN REVERSE
B IN 4S
C IN 8S
D IN 6P
A IN 4P
B IN F
C IN 1P
D IN W
A IN 9P
B IN N
C IN 9M
D IN B
A IN 7S
B IN 5P
C IN PASS
D IN 5M
A IN 7M
B IN 9S
C IN 1S
D IN 2P
A IN 3S
B IN 6S
C IN B
D IN 2S
A IN 9P
B IN 9M
C IN 4S
D IN 3M
A IN W
B IN 6P
C IN 8P
D IN W
A IN 2M
B IN 7P
C IN 6M
D IN 8M
A IN 2S
B IN...

result:

ok 175 lines

Test #3:

score: 0
Accepted
time: 211ms
memory: 89532kb

input:

6M
5S
2S
8S
5S
N
W
5S
6P
9P
3S
6S
8P
7P
5M
5M
7M
2S
4S
5M
REVERSE
F
9S
REVERSE
7S
B
2S
4M
3S
6P
2P
3M
N
8M
9M
REVERSE
7P
PASS
2S
1P
1M
N
8M
7M
W
1S
4M
2M
PASS
W
6P
7M
7P
3P
9S
4M
B
4S
6M
8S
6S
3P
2M
9S
9S
1S
1M
1P
2P
1S
2P
4P
9P
8P
S
9M
F
7S
1M
9P
E
S
8P
Z
8M
1P
2M
F
4P
B
DOUBLE
4S
E
3P
7S
DOUBLE
9P...

output:

A IN 6M
B IN 5S
C IN 2S
D IN 8S
A IN 5S
B IN N
C IN W
D IN 5S
A IN 6P
B IN 9P
C IN 3S
D IN 6S
A IN 8P
B IN 7P
C IN 5M
D IN 5M
A IN 7M
B IN 2S
C IN 4S
D IN 5M
A IN REVERSE
B IN F
C IN 9S
D IN REVERSE
A IN 7S
B IN B
C IN 2S
D IN 4M
A IN 3S
B IN 6P
C IN 2P
D IN 3M
A IN N
B IN 8M
C IN 9M
D IN REVERSE
A ...

result:

ok 168 lines

Test #4:

score: 0
Accepted
time: 201ms
memory: 89524kb

input:

6S
2S
5M
8P
5P
F
B
F
3S
8P
5P
9M
4S
6S
3S
Z
S
2P
2M
4S
2P
9S
4S
4P
2S
7S
REVERSE
3M
2M
E
9P
4P
9P
W
E
6P
PASS
S
2M
1M
3S
B
7M
3P
7S
DOUBLE
1S
6M
6P
Z
3P
5P
7S
9M
2P
6S
W
1M
S
E
REVERSE
1M
9M
W
PASS
1P
N
E
7P
1P
F
9S
9S
1P
W
8P
3P
N
3P
DOUBLE
4M
6M
2S
4M
1P
REVERSE
Z
B
6M
F
7M
5M
4M
3M
3S
S
DOUBLE
N
...

output:

A IN 6S
B IN 2S
C IN 5M
D IN 8P
A IN 5P
B IN F
C IN B
D IN F
A IN 3S
B IN 8P
C IN 5P
D IN 9M
A IN 4S
B IN 6S
C IN 3S
D IN Z
A IN S
B IN 2P
C IN 2M
D IN 4S
A IN 2P
B IN 9S
C IN 4S
D IN 4P
A IN 2S
B IN 7S
C IN REVERSE
D IN 3M
A IN 2M
B IN E
C IN 9P
D IN 4P
A IN 9P
B IN W
C IN E
D IN 6P
A IN PASS
B IN ...

result:

ok 128 lines

Test #5:

score: 0
Accepted
time: 202ms
memory: 89592kb

input:

5P
2P
5M
PASS
3S
8M
W
S
W
DOUBLE
9M
E
6S
9S
Z
4S
W
3S
6M
6S
DOUBLE
7M
1P
9M
9S
Z
9P
REVERSE
7M
1S
8S
2S
8P
DOUBLE
4S
4M
6S
3P
4S
3P
8S
REVERSE
1M
N
7M
8S
3P
6M
5P
3S
REVERSE
6P
N
6P
4P
PASS
E
8P
N
1S
9S
8M
7S
8P
3P
5M
6M
6M
9S
2M
6P
E
8P
PASS
2P
F
3M
N
1M
3M
B
F
1P
1P
1S
F
2S
5M
2S
4S
2M
4M
1M
2P
7P...

output:

A IN 5P
B IN 2P
C IN 5M
D IN PASS
A IN 3S
B IN 8M
C IN W
D IN S
A IN W
B IN DOUBLE
C IN 9M
D IN E
A IN 6S
B IN 9S
C IN Z
D IN 4S
A IN W
B IN 3S
C IN 6M
D IN 6S
A IN DOUBLE
B IN 7M
C IN 1P
D IN 9M
A IN 9S
B IN Z
C IN 9P
D IN REVERSE
A IN 7M
B IN 1S
C IN 8S
D IN 2S
A IN 8P
B IN DOUBLE
C IN 4S
D IN 4M
...

result:

ok 92 lines

Test #6:

score: 0
Accepted
time: 204ms
memory: 89612kb

input:

N
PASS
6S
4M
9M
1S
5M
5S
1S
7M
7S
2S
PASS
9S
4S
F
5P
7S
2S
5P
DOUBLE
5S
5M
2P
S
W
5S
4P
4S
9M
4P
3P
7S
REVERSE
8M
5P
6S
8M
7M
6M
3P
S
2S
2M
B
1P
6P
Z
6P
5M
6P
2P
2P
8M
2M
9M
4P
S
4S
Z
1M
2M
3M
6M
E
N
3M
8P
PASS
7M
6S
W
3S
4S
7P
3M
1M
1P
8P
F
W
Z
F
E
2M
9P
E
1S
B
7P
7P
Z
6P
5P
2P
F
4M
DOUBLE
1M
DOUBL...

output:

A IN N
B IN PASS
C IN 6S
D IN 4M
A IN 9M
B IN 1S
C IN 5M
D IN 5S
A IN 1S
B IN 7M
C IN 7S
D IN 2S
A IN PASS
B IN 9S
C IN 4S
D IN F
A IN 5P
B IN 7S
C IN 2S
D IN 5P
A IN DOUBLE
B IN 5S
C IN 5M
D IN 2P
A IN S
B IN W
C IN 5S
D IN 4P
A IN 4S
B IN 9M
C IN 4P
D IN 3P
A IN 7S
B IN REVERSE
C IN 8M
D IN 5P
A I...

result:

ok 98 lines

Test #7:

score: 0
Accepted
time: 213ms
memory: 89668kb

input:

9P
9P
3M
4S
E
6P
B
3S
5P
6M
2S
4P
9P
PASS
S
2S
B
9S
8P
4M
3P
5M
4P
1S
3S
N
3S
4M
1M
5M
1P
7S
9M
DOUBLE
6M
3M
9S
F
9P
4P
W
1P
Z
3S
DOUBLE
E
4M
6S
2P
5S
Z
7P
1S
4M
8S
5S
4P
1P
1M
2S
2S
5S
REVERSE
7M
B
5M
PASS
S
7M
2M
9M
8P
2M
E
N
6M
8S
7P
B
1S
7M
4S
7S
Z
3P
3M
8P
2M
DOUBLE
7P
PASS
2P
REVERSE
8S
F
3P
9...

output:

A IN 9P
B IN 9P
C IN 3M
D IN 4S
A IN E
B IN 6P
C IN B
D IN 3S
A IN 5P
B IN 6M
C IN 2S
D IN 4P
A IN 9P
B IN PASS
C IN S
D IN 2S
A IN B
B IN 9S
C IN 8P
D IN 4M
A IN 3P
B IN 5M
C IN 4P
D IN 1S
A IN 3S
B IN N
C IN 3S
D IN 4M
A IN 1M
B IN 5M
C IN 1P
D IN 7S
A IN 9M
B IN DOUBLE
C IN 6M
D IN 3M
A IN 9S
B I...

result:

ok 184 lines

Test #8:

score: 0
Accepted
time: 202ms
memory: 89536kb

input:

8M
PASS
1P
1S
5P
9S
3P
4P
4S
1P
7S
7S
2S
W
9M
F
4S
1S
1M
3S
6S
5S
PASS
3S
Z
B
5P
DOUBLE
2S
5S
E
1M
5S
F
9M
8S
2P
7P
5P
F
1P
3P
8S
1M
7S
REVERSE
7M
2M
1M
B
2M
6P
DOUBLE
4P
F
1P
3P
DOUBLE
PASS
2P
9S
4S
9S
2P
Z
3M
9P
8M
8P
6M
REVERSE
DOUBLE
Z
3M
N
4M
6M
B
6S
7M
S
4P
8P
6M
W
6P
E
5P
4M
9M
2M
Z
W
7P
PASS...

output:

A IN 8M
B IN PASS
C IN 1P
D IN 1S
A IN 5P
B IN 9S
C IN 3P
D IN 4P
A IN 4S
B IN 1P
C IN 7S
D IN 7S
A IN 2S
B IN W
C IN 9M
D IN F
A IN 4S
B IN 1S
C IN 1M
D IN 3S
A IN 6S
B IN 5S
C IN PASS
D IN 3S
A IN Z
B IN B
C IN 5P
D IN DOUBLE
A IN 2S
B IN 5S
C IN E
D IN 1M
A IN 5S
B IN F
C IN 9M
D IN 8S
A IN 2P
B ...

result:

ok 116 lines

Test #9:

score: 0
Accepted
time: 196ms
memory: 89680kb

input:

3S
6P
Z
7S
1P
Z
REVERSE
5M
1P
1S
7S
3M
3S
4S
1S
4S
4S
8P
8M
1P
2M
2M
6S
8S
9S
9P
E
F
2S
7P
3M
6P
9P
8P
4M
4P
S
9M
N
S
6S
3M
B
6M
7M
PASS
8P
6M
7M
8M
DOUBLE
2P
9S
W
5S
7P
4M
2S
1M
7S
4P
9M
2S
8S
1M
3P
5M
DOUBLE
9S
1S
7M
5P
W
9M
B
5P
6S
2M
DOUBLE
8S
5M
3S
8P
2P
E
5P
5S
4M
6P
3P
2P
REVERSE
9P
7P
F
9S
D...

output:

A IN 3S
B IN 6P
C IN Z
D IN 7S
A IN 1P
B IN Z
C IN REVERSE
D IN 5M
A IN 1P
B IN 1S
C IN 7S
D IN 3M
A IN 3S
B IN 4S
C IN 1S
D IN 4S
A IN 4S
B IN 8P
C IN 8M
D IN 1P
A IN 2M
B IN 2M
C IN 6S
D IN 8S
A IN 9S
B IN 9P
C IN E
D IN F
A IN 2S
B IN 7P
C IN 3M
D IN 6P
A IN 9P
B IN 8P
C IN 4M
D IN 4P
A IN S
B IN...

result:

ok 132 lines

Test #10:

score: 0
Accepted
time: 202ms
memory: 89528kb

input:

9P
2M
4S
6P
9M
S
5S
8P
REVERSE
5S
9P
8M
N
F
Z
7P
1M
DOUBLE
5P
2S
2P
8P
6S
3M
9M
N
N
6P
7S
S
2M
4M
3S
6S
8S
5M
1M
7P
1M
PASS
PASS
8P
5M
2S
1S
E
5M
PASS
W
B
3S
6P
9S
3P
W
8S
4M
8M
9S
7M
PASS
5M
6M
3S
7M
9S
9P
4P
4M
2S
7P
2S
9M
REVERSE
3P
W
4P
1P
2M
N
1S
8S
5P
6P
6S
DOUBLE
8P
REVERSE
7M
B
1S
F
4S
S
1P
...

output:

A IN 9P
B IN 2M
C IN 4S
D IN 6P
A IN 9M
B IN S
C IN 5S
D IN 8P
A IN REVERSE
B IN 5S
C IN 9P
D IN 8M
A IN N
B IN F
C IN Z
D IN 7P
A IN 1M
B IN DOUBLE
C IN 5P
D IN 2S
A IN 2P
B IN 8P
C IN 6S
D IN 3M
A IN 9M
B IN N
C IN N
D IN 6P
A IN 7S
B IN S
C IN 2M
D IN 4M
A IN 3S
B IN 6S
C IN 8S
D IN 5M
A IN 1M
B ...

result:

ok 164 lines

Test #11:

score: 0
Accepted
time: 199ms
memory: 89612kb

input:

7M
7M
Z
8M
PASS
2M
6P
F
5S
E
8S
3M
6P
3M
5M
2P
9S
2S
2S
Z
4M
9M
6M
REVERSE
3P
N
8S
S
3S
REVERSE
DOUBLE
7S
5S
5P
7M
W
W
5S
1M
7S
2P
1M
B
1P
7M
6P
6M
4P
6M
9S
5M
4M
4M
8S
8M
PASS
5P
1S
2P
5M
8P
PASS
3S
DOUBLE
8M
2P
8M
7S
6S
B
DOUBLE
2S
E
4P
B
4S
E
2M
7P
8P
5M
B
3M
F
E
9M
9S
S
3M
N
4P
4S
Z
7P
7P
1P
PAS...

output:

A IN 7M
B IN 7M
C IN Z
D IN 8M
A IN PASS
B IN 2M
C IN 6P
D IN F
A IN 5S
B IN E
C IN 8S
D IN 3M
A IN 6P
B IN 3M
C IN 5M
D IN 2P
A IN 9S
B IN 2S
C IN 2S
D IN Z
A IN 4M
B IN 9M
C IN 6M
D IN REVERSE
A IN 3P
B IN N
C IN 8S
D IN S
A IN 3S
B IN REVERSE
C IN DOUBLE
D IN 7S
A IN 5S
B IN 5P
C IN 7M
D IN W
A I...

result:

ok 160 lines

Test #12:

score: 0
Accepted
time: 213ms
memory: 89668kb

input:

8M
3P
4S
E
7S
9S
2M
Z
1P
8S
7M
DOUBLE
DOUBLE
DOUBLE
7P
7S
5P
1M
B
N
B
4M
1S
3M
9P
6S
9M
1P
REVERSE
8P
9S
7S
F
2M
1S
5P
8P
8P
7P
B
9P
9P
3M
REVERSE
3P
3M
3S
7P
5P
2P
W
6M
1M
6M
2S
6S
2P
8M
PASS
3S
F
4P
3P
PASS
REVERSE
4S
7P
7M
5M
4P
REVERSE
8M
W
E
5P
S
F
2P
9M
4M
2M
4P
5S
3S
2S
DOUBLE
9M
W
1P
1S
1M
9...

output:

A IN 8M
B IN 3P
C IN 4S
D IN E
A IN 7S
B IN 9S
C IN 2M
D IN Z
A IN 1P
B IN 8S
C IN 7M
D IN DOUBLE
A IN DOUBLE
B IN DOUBLE
C IN 7P
D IN 7S
A IN 5P
B IN 1M
C IN B
D IN N
A IN B
B IN 4M
C IN 1S
D IN 3M
A IN 9P
B IN 6S
C IN 9M
D IN 1P
A IN REVERSE
B IN 8P
C IN 9S
D IN 7S
A IN F
B IN 2M
C IN 1S
D IN 5P
A...

result:

ok 224 lines

Test #13:

score: 0
Accepted
time: 198ms
memory: 89524kb

input:

4P
8S
W
8S
1P
6M
E
B
5S
5S
5M
5S
DOUBLE
9P
9M
4M
4S
2M
4S
1M
1S
5M
1S
N
Z
F
3S
8S
3M
2P
9P
2M
7M
2M
8M
9S
4P
9M
S
8P
3P
S
DOUBLE
7P
9P
3P
5S
7P
9M
2S
5M
B
3P
6S
REVERSE
9S
7M
3S
9P
7P
F
1M
6M
6P
E
N
6M
3P
7S
4M
2S
DOUBLE
S
4P
F
7S
8P
5P
4P
7M
B
5P
3M
REVERSE
8M
1P
N
1M
1P
2S
3M
3S
8P
5M
8M
Z
E
8M
2M...

output:

A IN 4P
B IN 8S
C IN W
D IN 8S
A IN 1P
B IN 6M
C IN E
D IN B
A IN 5S
B IN 5S
C IN 5M
D IN 5S
A IN DOUBLE
B IN 9P
C IN 9M
D IN 4M
A IN 4S
B IN 2M
C IN 4S
D IN 1M
A IN 1S
B IN 5M
C IN 1S
D IN N
A IN Z
B IN F
C IN 3S
D IN 8S
A IN 3M
B IN 2P
C IN 9P
D IN 2M
A IN 7M
B IN 2M
C IN 8M
D IN 9S
A IN 4P
B IN 9...

result:

ok 164 lines

Test #14:

score: 0
Accepted
time: 214ms
memory: 89608kb

input:

5S
2M
7M
5M
2P
W
1M
REVERSE
W
5M
REVERSE
DOUBLE
4M
N
1S
5S
3M
2M
8P
7S
B
7P
9P
9S
6M
9M
F
8P
9M
2P
DOUBLE
Z
PASS
3S
PASS
9S
S
5P
1P
7M
2S
6P
2M
S
6M
6P
3S
8P
9M
4P
5P
2S
1M
1S
N
6M
8S
1M
8S
8M
3M
7M
S
7M
3S
S
9P
8P
5P
3P
7P
7P
9M
6S
5S
4M
9S
6P
REVERSE
8M
7S
1P
1M
3P
W
4M
1S
5S
8M
W
6S
REVERSE
E
3M
...

output:

A IN 5S
B IN 2M
C IN 7M
D IN 5M
A IN 2P
B IN W
C IN 1M
D IN REVERSE
A IN W
B IN 5M
C IN REVERSE
D IN DOUBLE
A IN 4M
B IN N
C IN 1S
D IN 5S
A IN 3M
B IN 2M
C IN 8P
D IN 7S
A IN B
B IN 7P
C IN 9P
D IN 9S
A IN 6M
B IN 9M
C IN F
D IN 8P
A IN 9M
B IN 2P
C IN DOUBLE
D IN Z
A IN PASS
B IN 3S
C IN PASS
D IN...

result:

ok 251 lines

Test #15:

score: 0
Accepted
time: 194ms
memory: 89524kb

input:

N
3P
W
1P
1M
2S
4M
S
7P
2S
7S
1S
7P
9M
6P
F
2M
5M
4S
7M
3M
8M
7M
Z
E
7S
9M
8P
9M
B
7M
3P
1M
7S
B
Z
3P
4M
1P
4M
3S
W
8P
W
DOUBLE
E
4S
1S
9M
4S
6M
8S
DOUBLE
9S
PASS
8S
5S
DOUBLE
7S
5S
E
4M
3S
5S
N
F
8M
2M
REVERSE
5M
7P
6P
N
5P
3M
1M
5P
9P
8M
E
8S
9S
2P
B
1S
1P
Z
REVERSE
9S
F
PASS
4S
4P
S
5M
6S
2S
7M
9...

output:

A IN N
B IN 3P
C IN W
D IN 1P
A IN 1M
B IN 2S
C IN 4M
D IN S
A IN 7P
B IN 2S
C IN 7S
D IN 1S
A IN 7P
B IN 9M
C IN 6P
D IN F
A IN 2M
B IN 5M
C IN 4S
D IN 7M
A IN 3M
B IN 8M
C IN 7M
D IN Z
A IN E
B IN 7S
C IN 9M
D IN 8P
A IN 9M
B IN B
C IN 7M
D IN 3P
A IN 1M
B IN 7S
C IN B
D IN Z
A IN 3P
B IN 4M
C IN ...

result:

ok 251 lines

Test #16:

score: 0
Accepted
time: 200ms
memory: 89524kb

input:

7S
F
1M
7M
PASS
8S
1P
5S
4P
REVERSE
4P
4P
9M
PASS
7M
4S
2P
2P
3M
3M
1P
PASS
N
7P
9M
W
B
3S
Z
8M
DOUBLE
7S
S
8M
7P
B
1P
9P
3P
7M
4P
8S
9P
PASS
F
2S
9S
9S
9S
B
W
5S
2M
E
B
6M
5M
1P
6S
4M
3P
F
8M
1S
DOUBLE
9M
8M
4S
4M
7M
2P
2S
2M
8P
2M
Z
E
5P
5S
6P
7S
N
6M
3S
3S
3M
5M
REVERSE
S
REVERSE
8P
3P
1S
1S
REVE...

output:

A IN 7S
B IN F
C IN 1M
D IN 7M
A IN PASS
B IN 8S
C IN 1P
D IN 5S
A IN 4P
B IN REVERSE
C IN 4P
D IN 4P
A IN 9M
B IN PASS
C IN 7M
D IN 4S
A IN 2P
B IN 2P
C IN 3M
D IN 3M
A IN 1P
B IN PASS
C IN N
D IN 7P
A IN 9M
B IN W
C IN B
D IN 3S
A IN Z
B IN 8M
C IN DOUBLE
D IN 7S
A IN S
B IN 8M
C IN 7P
D IN B
A IN...

result:

ok 253 lines

Test #17:

score: 0
Accepted
time: 203ms
memory: 89500kb

input:

7M
1S
1S
4M
6S
7M
7S
W
2P
4P
REVERSE
W
4S
N
S
DOUBLE
W
8S
Z
3M
3S
PASS
7M
8S
3P
1P
B
N
8P
W
PASS
6M
3S
2M
7P
3M
2S
1M
PASS
4S
4M
5M
DOUBLE
3P
9M
9S
1M
7M
3P
7S
8M
9M
2S
Z
5S
Z
6P
9P
4P
E
S
7S
7S
5P
9S
B
5S
4P
5M
2P
1M
8S
9S
9P
F
5M
6P
REVERSE
8M
E
8P
4S
DOUBLE
F
6M
B
9M
2S
9P
2M
4S
4M
4M
REVERSE
PAS...

output:

A IN 7M
B IN 1S
C IN 1S
D IN 4M
A IN 6S
B IN 7M
C IN 7S
D IN W
A IN 2P
B IN 4P
C IN REVERSE
D IN W
A IN 4S
B IN N
C IN S
D IN DOUBLE
A IN W
B IN 8S
C IN Z
D IN 3M
A IN 3S
B IN PASS
C IN 7M
D IN 8S
A IN 3P
B IN 1P
C IN B
D IN N
A IN 8P
B IN W
C IN PASS
D IN 6M
A IN 3S
B IN 2M
C IN 7P
D IN 3M
A IN 2S
...

result:

ok 255 lines

Test #18:

score: 0
Accepted
time: 204ms
memory: 89612kb

input:

8S
E
5S
2S
6M
9S
3M
7S
8P
4S
S
N
2S
E
7P
DOUBLE
5P
F
9P
2M
8P
3S
F
DOUBLE
S
2M
1S
3M
6P
DOUBLE
3S
E
REVERSE
N
3S
7P
8S
3P
Z
4S
1P
4S
1M
8S
B
8M
4P
5S
8M
4M
5M
7M
B
8P
7P
3M
Z
4P
DOUBLE
6M
7M
PASS
8S
2P
W
B
6P
6P
PASS
6M
2M
6S
4P
5S
2S
F
N
9S
2S
9P
9S
8M
S
7S
7M
5P
7M
9M
3S
9S
9P
S
B
1P
1M
REVERSE
1S...

output:

A IN 8S
B IN E
C IN 5S
D IN 2S
A IN 6M
B IN 9S
C IN 3M
D IN 7S
A IN 8P
B IN 4S
C IN S
D IN N
A IN 2S
B IN E
C IN 7P
D IN DOUBLE
A IN 5P
B IN F
C IN 9P
D IN 2M
A IN 8P
B IN 3S
C IN F
D IN DOUBLE
A IN S
B IN 2M
C IN 1S
D IN 3M
A IN 6P
B IN DOUBLE
C IN 3S
D IN E
A IN REVERSE
B IN N
C IN 3S
D IN 7P
A IN...

result:

ok 251 lines

Test #19:

score: 0
Accepted
time: 194ms
memory: 89592kb

input:

8P
S
4M
8M
PASS
6S
4P
B
S
7P
6S
4M
9P
6P
F
7P
DOUBLE
5P
W
9P
4M
9M
3M
3S
5S
5P
6M
4P
7M
W
8P
1P
Z
8S
3M
1M
W
3S
Z
9S
4S
7S
Z
5M
9S
7S
4S
7M
7P
9P
2S
REVERSE
4S
7P
PASS
6S
1P
5M
4P
DOUBLE
5S
N
9S
6P
6M
B
1M
5S
2S
1M
7S
2M
REVERSE
1P
6P
PASS
F
W
1S
1S
1M
2M
4S
9P
8S
2P
9M
E
8M
2P
8M
N
8M
7S
2M
S
6M
3S...

output:

A IN 8P
B IN S
C IN 4M
D IN 8M
A IN PASS
B IN 6S
C IN 4P
D IN B
A IN S
B IN 7P
C IN 6S
D IN 4M
A IN 9P
B IN 6P
C IN F
D IN 7P
A IN DOUBLE
B IN 5P
C IN W
D IN 9P
A IN 4M
B IN 9M
C IN 3M
D IN 3S
A IN 5S
B IN 5P
C IN 6M
D IN 4P
A IN 7M
B IN W
C IN 8P
D IN 1P
A IN Z
B IN 8S
C IN 3M
D IN 1M
A IN W
B IN 3...

result:

ok 236 lines

Test #20:

score: 0
Accepted
time: 203ms
memory: 89584kb

input:

6P
2S
8M
4P
REVERSE
1S
3M
7P
S
E
4S
REVERSE
6S
S
5M
4M
7M
6P
DOUBLE
Z
9P
PASS
6M
4S
W
S
9M
7S
5S
2P
W
5S
1P
Z
3M
6P
N
2P
2S
3P
1M
B
8M
PASS
3S
2M
8S
9S
3S
8P
6S
3M
F
5M
6M
1M
6S
4S
N
5P
E
2S
5M
6S
9S
2P
1P
B
5P
DOUBLE
F
7P
N
8P
DOUBLE
8S
1S
Z
6P
4M
7S
2S
3P
9S
5S
7P
7P
6M
1M
E
DOUBLE
4S
8M
5P
5M
2M
...

output:

A IN 6P
B IN 2S
C IN 8M
D IN 4P
A IN REVERSE
B IN 1S
C IN 3M
D IN 7P
A IN S
B IN E
C IN 4S
D IN REVERSE
A IN 6S
B IN S
C IN 5M
D IN 4M
A IN 7M
B IN 6P
C IN DOUBLE
D IN Z
A IN 9P
B IN PASS
C IN 6M
D IN 4S
A IN W
B IN S
C IN 9M
D IN 7S
A IN 5S
B IN 2P
C IN W
D IN 5S
A IN 1P
B IN Z
C IN 3M
D IN 6P
A IN...

result:

ok 146 lines

Test #21:

score: 0
Accepted
time: 207ms
memory: 89536kb

input:

2P
3P
3S
2M
E
4S
1P
5S
DOUBLE
5P
1S
2P
9S
6P
9M
1S
4P
Z
N
4S
S
8M
PASS
PASS
8M
6S
7M
4M
6M
9P
DOUBLE
1P
1M
3S
Z
Z
3M
2S
6P
8S
S
5S
W
8S
3P
1S
6P
E
9P
F
4P
7M
4P
F
3M
8P
6M
N
1P
1P
7P
W
2P
5P
4S
5M
7M
9S
5P
5S
2P
N
S
5M
4M
9M
5M
8P
7S
7S
3P
REVERSE
B
F
4M
F
DOUBLE
2M
7P
6P
3M
9P
B
8S
5P
DOUBLE
7M
6S
...

output:

A IN 2P
B IN 3P
C IN 3S
D IN 2M
A IN E
B IN 4S
C IN 1P
D IN 5S
A IN DOUBLE
B IN 5P
C IN 1S
D IN 2P
A IN 9S
B IN 6P
C IN 9M
D IN 1S
A IN 4P
B IN Z
C IN N
D IN 4S
A IN S
B IN 8M
C IN PASS
D IN PASS
A IN 8M
B IN 6S
C IN 7M
D IN 4M
A IN 6M
B IN 9P
C IN DOUBLE
D IN 1P
A IN 1M
B IN 3S
C IN Z
D IN Z
A IN 3...

result:

ok 166 lines

Test #22:

score: 0
Accepted
time: 205ms
memory: 89596kb

input:

2S
PASS
3P
Z
9S
F
7S
PASS
8M
N
8P
1M
6S
5S
8S
1M
3M
3S
4M
2M
6M
1M
9M
7P
5P
E
E
6S
W
5M
8M
7P
REVERSE
PASS
5S
B
6P
4S
2P
W
1S
6M
2P
2P
N
7P
1P
4M
5P
2M
7S
F
1P
8M
F
4M
3P
7S
8P
4P
Z
4P
4S
REVERSE
S
6M
9S
F
8P
9P
6P
9M
B
9P
5P
1S
S
N
6M
DOUBLE
4S
DOUBLE
Z
3M
2P
9P
Z
2S
8S
S
3S
4M
PASS
5M
E
8M
1S
7M
2...

output:

A IN 2S
B IN PASS
C IN 3P
D IN Z
A IN 9S
B IN F
C IN 7S
D IN PASS
A IN 8M
B IN N
C IN 8P
D IN 1M
A IN 6S
B IN 5S
C IN 8S
D IN 1M
A IN 3M
B IN 3S
C IN 4M
D IN 2M
A IN 6M
B IN 1M
C IN 9M
D IN 7P
A IN 5P
B IN E
C IN E
D IN 6S
A IN W
B IN 5M
C IN 8M
D IN 7P
A IN REVERSE
B IN PASS
C IN 5S
D IN B
A IN 6P
...

result:

ok 206 lines

Test #23:

score: 0
Accepted
time: 193ms
memory: 89596kb

input:

3M
7M
6S
E
7S
3M
1S
E
F
N
4M
2S
8S
Z
W
5P
8M
E
B
5S
5P
S
3S
7S
1S
4P
6M
1S
F
PASS
1M
7M
Z
1M
9S
5M
8S
9M
4S
4M
7S
F
9P
3S
2P
9M
1P
9P
F
B
9P
4M
5S
1M
9S
9M
6S
N
6M
4S
S
6P
4P
2M
6M
7M
8P
4P
E
REVERSE
REVERSE
2M
8M
9S
W
B
W
REVERSE
PASS
5S
7P
2P
8P
6S
5P
8S
3M
1P
8P
3P
Z
8P
7M
5P
4S
6P
2S
6P
B
7P
3S
...

output:

A IN 3M
B IN 7M
C IN 6S
D IN E
A IN 7S
B IN 3M
C IN 1S
D IN E
A IN F
B IN N
C IN 4M
D IN 2S
A IN 8S
B IN Z
C IN W
D IN 5P
A IN 8M
B IN E
C IN B
D IN 5S
A IN 5P
B IN S
C IN 3S
D IN 7S
A IN 1S
B IN 4P
C IN 6M
D IN 1S
A IN F
B IN PASS
C IN 1M
D IN 7M
A IN Z
B IN 1M
C IN 9S
D IN 5M
A IN 8S
B IN 9M
C IN ...

result:

ok 152 lines

Test #24:

score: 0
Accepted
time: 216ms
memory: 89620kb

input:

S
7S
E
5P
2P
8S
2M
7P
4M
B
7S
5P
7M
S
F
3S
5S
3S
1M
6S
4S
1S
Z
2M
1P
4M
6P
N
W
1P
REVERSE
1M
3M
2P
DOUBLE
2S
3P
8M
7M
6P
6S
4S
PASS
7M
4M
8S
8S
2P
F
5S
5M
1S
9M
9S
7P
F
8M
4S
DOUBLE
5M
W
1S
1S
8P
2P
1M
7S
9M
DOUBLE
5S
2S
7P
8P
E
9P
4P
W
8M
1P
6S
2S
6M
2M
4P
6M
7S
3P
N
9M
3M
REVERSE
2S
Z
1P
PASS
S
W
...

output:

A IN S
B IN 7S
C IN E
D IN 5P
A IN 2P
B IN 8S
C IN 2M
D IN 7P
A IN 4M
B IN B
C IN 7S
D IN 5P
A IN 7M
B IN S
C IN F
D IN 3S
A IN 5S
B IN 3S
C IN 1M
D IN 6S
A IN 4S
B IN 1S
C IN Z
D IN 2M
A IN 1P
B IN 4M
C IN 6P
D IN N
A IN W
B IN 1P
C IN REVERSE
D IN 1M
A IN 3M
B IN 2P
C IN DOUBLE
D IN 2S
A IN 3P
B I...

result:

ok 170 lines

Test #25:

score: 0
Accepted
time: 208ms
memory: 89524kb

input:

6P
1P
9S
7M
PASS
REVERSE
N
4P
8P
6S
F
8P
1M
3P
6P
DOUBLE
5S
Z
6M
9P
4S
B
8M
N
1P
2M
2P
6P
7P
7S
4S
4M
3P
F
9S
5M
9M
6P
N
PASS
1M
9P
9M
DOUBLE
5P
S
W
7S
8S
2P
4P
4P
E
S
4M
2P
7S
5P
W
Z
3M
3M
6S
5M
9S
PASS
E
1S
B
3S
5P
9S
3S
F
6S
3S
6M
W
2S
E
1P
N
7S
W
Z
5P
4M
2M
2M
5M
4S
6M
1S
7M
3M
S
8S
PASS
REVERSE...

output:

A IN 6P
B IN 1P
C IN 9S
D IN 7M
A IN PASS
B IN REVERSE
C IN N
D IN 4P
A IN 8P
B IN 6S
C IN F
D IN 8P
A IN 1M
B IN 3P
C IN 6P
D IN DOUBLE
A IN 5S
B IN Z
C IN 6M
D IN 9P
A IN 4S
B IN B
C IN 8M
D IN N
A IN 1P
B IN 2M
C IN 2P
D IN 6P
A IN 7P
B IN 7S
C IN 4S
D IN 4M
A IN 3P
B IN F
C IN 9S
D IN 5M
A IN 9M...

result:

ok 128 lines

Test #26:

score: 0
Accepted
time: 191ms
memory: 89584kb

input:

E
E
8P
3P
5S
9P
9M
4P
4S
1P
F
3P
6P
6M
5M
9S
2P
7M
9S
DOUBLE
PASS
6S
2S
9P
S
1M
DOUBLE
Z
N
5P
REVERSE
2P
2M
1M
9P
9P
Z
1S
6P
7S
1S
DOUBLE
1P
3P
F
7S
8P
3S
B
8M
2M
B
4M
W
9S
2S
B
5M
7P
1S
4M
2S
3M
9M
6S
8M
PASS
5M
2P
Z
8M
7P
N
8S
W
4P
N
7P
1M
B
5S
8S
F
8P
1M
5P
6S
1P
1S
6M
4M
2M
3S
S
W
F
7P
7S
4S
5S
...

output:

A IN E
B IN E
C IN 8P
D IN 3P
A IN 5S
B IN 9P
C IN 9M
D IN 4P
A IN 4S
B IN 1P
C IN F
D IN 3P
A IN 6P
B IN 6M
C IN 5M
D IN 9S
A IN 2P
B IN 7M
C IN 9S
D IN DOUBLE
A IN PASS
B IN 6S
C IN 2S
D IN 9P
A IN S
B IN 1M
C IN DOUBLE
D IN Z
A IN N
B IN 5P
C IN REVERSE
D IN 2P
A IN 2M
B IN 1M
C IN 9P
D IN 9P
A I...

result:

ok 186 lines

Test #27:

score: 0
Accepted
time: 217ms
memory: 89608kb

input:

6P
1S
9S
4M
N
5S
B
PASS
5M
F
3S
2P
8S
2S
3P
4M
9P
9S
8P
8P
N
6M
Z
7S
4M
4S
1M
4S
4S
PASS
3S
7S
3P
9P
W
3S
9P
1S
4P
8M
4P
5S
5M
Z
5S
S
DOUBLE
9M
Z
7M
6S
B
8P
5M
W
5P
6M
8S
9M
1S
8M
6S
7M
7S
REVERSE
S
3M
6P
4S
3M
E
3M
1M
5P
9M
DOUBLE
3P
4P
5M
7M
E
7P
S
7P
2S
6P
6S
REVERSE
REVERSE
N
7P
2M
B
PASS
B
1P
4...

output:

A IN 6P
B IN 1S
C IN 9S
D IN 4M
A IN N
B IN 5S
C IN B
D IN PASS
A IN 5M
B IN F
C IN 3S
D IN 2P
A IN 8S
B IN 2S
C IN 3P
D IN 4M
A IN 9P
B IN 9S
C IN 8P
D IN 8P
A IN N
B IN 6M
C IN Z
D IN 7S
A IN 4M
B IN 4S
C IN 1M
D IN 4S
A IN 4S
B IN PASS
C IN 3S
D IN 7S
A IN 3P
B IN 9P
C IN W
D IN 3S
A IN 9P
B IN 1...

result:

ok 126 lines

Test #28:

score: 0
Accepted
time: 197ms
memory: 89664kb

input:

6S
6P
REVERSE
4S
3M
DOUBLE
4M
9M
REVERSE
S
3S
F
1S
8S
W
6M
5P
B
B
8M
DOUBLE
B
N
S
3S
4S
1M
7P
9M
2P
6M
1M
5P
1S
2M
5S
PASS
3S
9P
4M
6P
4M
E
PASS
6P
4P
8M
Z
2P
2S
4S
9S
5M
3P
N
2M
8P
E
N
2S
E
5S
9P
1P
6S
1S
7M
5P
4M
8M
5S
9P
9S
7S
REVERSE
7M
8S
5S
1M
N
PASS
REVERSE
7P
W
F
7P
7M
S
6S
9S
2S
1P
5M
6P
3M...

output:

A IN 6S
B IN 6P
C IN REVERSE
D IN 4S
A IN 3M
B IN DOUBLE
C IN 4M
D IN 9M
A IN REVERSE
B IN S
C IN 3S
D IN F
A IN 1S
B IN 8S
C IN W
D IN 6M
A IN 5P
B IN B
C IN B
D IN 8M
A IN DOUBLE
B IN B
C IN N
D IN S
A IN 3S
B IN 4S
C IN 1M
D IN 7P
A IN 9M
B IN 2P
C IN 6M
D IN 1M
A IN 5P
B IN 1S
C IN 2M
D IN 5S
A ...

result:

ok 159 lines

Test #29:

score: 0
Accepted
time: 201ms
memory: 89468kb

input:

2M
E
6S
F
7M
F
7M
4M
3M
9S
8S
PASS
W
W
8P
S
4M
7P
9P
1S
3M
5M
2M
S
2P
7S
B
8P
2P
5M
Z
N
5P
6P
8M
3S
2S
5S
5P
9S
REVERSE
2S
5S
3P
5S
9M
5P
7S
Z
1M
N
B
6M
7S
REVERSE
8S
6P
3P
5P
B
PASS
8P
W
7M
REVERSE
PASS
9M
1M
5M
3S
9P
4M
9S
9M
DOUBLE
4S
S
1P
4S
B
6S
4P
6M
4P
DOUBLE
1P
6P
E
2S
6M
4M
2M
6S
E
PASS
2P
...

output:

A IN 2M
B IN E
C IN 6S
D IN F
A IN 7M
B IN F
C IN 7M
D IN 4M
A IN 3M
B IN 9S
C IN 8S
D IN PASS
A IN W
B IN W
C IN 8P
D IN S
A IN 4M
B IN 7P
C IN 9P
D IN 1S
A IN 3M
B IN 5M
C IN 2M
D IN S
A IN 2P
B IN 7S
C IN B
D IN 8P
A IN 2P
B IN 5M
C IN Z
D IN N
A IN 5P
B IN 6P
C IN 8M
D IN 3S
A IN 2S
B IN 5S
C IN...

result:

ok 165 lines

Test #30:

score: 0
Accepted
time: 199ms
memory: 89632kb

input:

1S
5S
E
6M
DOUBLE
S
8S
3P
6P
E
2M
6P
7M
8P
2P
9M
1M
5P
4P
1M
7M
1M
PASS
3S
REVERSE
7M
9P
3M
REVERSE
7P
4M
5S
1M
1S
N
8M
6M
7P
3M
W
REVERSE
9M
3P
N
N
3M
Z
8S
6P
6M
6S
3P
DOUBLE
2S
6S
Z
7M
9P
PASS
9S
1P
9P
5P
5M
7S
PASS
6P
2M
5P
3S
7S
5S
5S
5P
2P
8P
5M
8M
3P
7P
1P
9S
8S
2P
S
8P
W
E
4S
4M
4P
3M
7P
2S
N...

output:

A IN 1S
B IN 5S
C IN E
D IN 6M
A IN DOUBLE
B IN S
C IN 8S
D IN 3P
A IN 6P
B IN E
C IN 2M
D IN 6P
A IN 7M
B IN 8P
C IN 2P
D IN 9M
A IN 1M
B IN 5P
C IN 4P
D IN 1M
A IN 7M
B IN 1M
C IN PASS
D IN 3S
A IN REVERSE
B IN 7M
C IN 9P
D IN 3M
A IN REVERSE
B IN 7P
C IN 4M
D IN 5S
A IN 1M
B IN 1S
C IN N
D IN 8M
...

result:

ok 110 lines

Test #31:

score: 0
Accepted
time: 206ms
memory: 89472kb

input:

4P
6P
2P
3P
3M
5M
4M
2M
5P
9S
4P
Z
PASS
6S
E
9S
4P
S
4P
2S
6S
2P
6M
W
3M
7P
REVERSE
9M
Z
S
6S
9S
1M
PASS
6P
1M
2S
1S
3P
8S
Z
5M
B
1S
1P
3M
6P
9P
4S
5S
7P
2M
4M
W
7M
5P
7S
8P
6M
8M
7P
1P
N
8M
1P
W
5P
2S
9S
3S
3S
DOUBLE
PASS
4M
6M
PASS
7P
8S
2S
8P
E
9M
REVERSE
1S
F
8S
N
DOUBLE
5S
7S
4S
6M
6S
2P
DOUBLE...

output:

A IN 4P
B IN 6P
C IN 2P
D IN 3P
A IN 3M
B IN 5M
C IN 4M
D IN 2M
A IN 5P
B IN 9S
C IN 4P
D IN Z
A IN PASS
B IN 6S
C IN E
D IN 9S
A IN 4P
B IN S
C IN 4P
D IN 2S
A IN 6S
B IN 2P
C IN 6M
D IN W
A IN 3M
B IN 7P
C IN REVERSE
D IN 9M
A IN Z
B IN S
C IN 6S
D IN 9S
A IN 1M
B IN PASS
C IN 6P
D IN 1M
A IN 2S
B...

result:

ok 159 lines

Test #32:

score: 0
Accepted
time: 198ms
memory: 89500kb

input:

9P
8M
7S
8S
DOUBLE
PASS
8P
PASS
5S
9S
4M
5S
9S
1S
2P
8S
9S
F
3M
7P
7S
6S
2P
3M
1P
2S
1S
F
2P
2M
8P
1M
8S
1S
1S
W
1M
REVERSE
B
5P
3M
W
3S
8P
B
7S
S
REVERSE
2S
5M
7P
6P
PASS
4S
REVERSE
5S
9P
B
4M
3P
6P
5M
1P
4S
8P
7P
Z
6P
8M
4M
7M
5S
7M
DOUBLE
1P
9S
2M
2M
3S
6S
6M
E
F
5P
2M
3P
6S
9P
4P
3M
4P
E
7P
8M
9...

output:

A IN 9P
B IN 8M
C IN 7S
D IN 8S
A IN DOUBLE
B IN PASS
C IN 8P
D IN PASS
A IN 5S
B IN 9S
C IN 4M
D IN 5S
A IN 9S
B IN 1S
C IN 2P
D IN 8S
A IN 9S
B IN F
C IN 3M
D IN 7P
A IN 7S
B IN 6S
C IN 2P
D IN 3M
A IN 1P
B IN 2S
C IN 1S
D IN F
A IN 2P
B IN 2M
C IN 8P
D IN 1M
A IN 8S
B IN 1S
C IN 1S
D IN W
A IN 1M...

result:

ok 146 lines

Test #33:

score: 0
Accepted
time: 199ms
memory: 89520kb

input:

6M
4P
7P
Z
N
REVERSE
7M
E
Z
B
4S
2M
7S
9P
4P
S
REVERSE
W
8P
2P
2M
9S
1M
5M
3S
8M
1P
1P
5S
3M
8P
8M
PASS
6S
3S
5M
DOUBLE
DOUBLE
5P
6S
3M
9S
3M
2M
B
N
3S
8S
9S
6P
2M
8P
6P
6P
1P
5M
3P
4M
4M
1M
4P
5P
4P
REVERSE
N
6S
E
3P
9M
3M
8S
S
E
3P
7P
W
6P
PASS
8S
5S
F
7S
8M
7P
7M
W
9P
6M
PASS
2S
8P
9M
PASS
2P
S
1...

output:

A IN 6M
B IN 4P
C IN 7P
D IN Z
A IN N
B IN REVERSE
C IN 7M
D IN E
A IN Z
B IN B
C IN 4S
D IN 2M
A IN 7S
B IN 9P
C IN 4P
D IN S
A IN REVERSE
B IN W
C IN 8P
D IN 2P
A IN 2M
B IN 9S
C IN 1M
D IN 5M
A IN 3S
B IN 8M
C IN 1P
D IN 1P
A IN 5S
B IN 3M
C IN 8P
D IN 8M
A IN PASS
B IN 6S
C IN 3S
D IN 5M
A IN DO...

result:

ok 138 lines

Test #34:

score: 0
Accepted
time: 206ms
memory: 89680kb

input:

6M
8M
7S
5S
6S
6M
9P
5P
2P
6P
7P
PASS
F
3M
2M
DOUBLE
2S
8S
E
5M
8S
W
4S
3S
8P
5P
1S
F
4P
4P
N
5P
DOUBLE
9M
1P
E
1P
4M
7P
5S
W
6M
9S
PASS
3P
1M
8M
1P
7M
6S
3P
9M
8P
5M
7M
F
9S
2P
Z
4S
7P
3M
4S
9M
5P
6P
3P
9S
8M
2M
7P
2S
6S
8M
4P
REVERSE
DOUBLE
3M
3M
1S
4P
9P
1S
2S
1M
N
1M
PASS
S
Z
E
F
8P
1S
REVERSE
7...

output:

A IN 6M
B IN 8M
C IN 7S
D IN 5S
A IN 6S
B IN 6M
C IN 9P
D IN 5P
A IN 2P
B IN 6P
C IN 7P
D IN PASS
A IN F
B IN 3M
C IN 2M
D IN DOUBLE
A IN 2S
B IN 8S
C IN E
D IN 5M
A IN 8S
B IN W
C IN 4S
D IN 3S
A IN 8P
B IN 5P
C IN 1S
D IN F
A IN 4P
B IN 4P
C IN N
D IN 5P
A IN DOUBLE
B IN 9M
C IN 1P
D IN E
A IN 1P
...

result:

ok 184 lines

Test #35:

score: 0
Accepted
time: 213ms
memory: 89472kb

input:

1M
DOUBLE
3S
9P
6S
3M
S
6P
2S
7S
1S
6M
5M
3S
7S
9M
2P
6M
F
6P
5M
3P
9S
E
2M
9P
6P
5P
S
S
8P
B
W
1M
S
F
5S
PASS
REVERSE
1S
Z
6S
6M
6S
4P
1S
7S
2P
3P
3S
4P
8P
9P
E
REVERSE
7P
4S
8S
F
F
3P
7P
8P
PASS
1P
DOUBLE
4P
W
1M
8P
N
1P
9M
PASS
N
N
REVERSE
7M
4M
3M
7P
2S
8M
7M
8S
2M
6S
5S
7P
5S
E
W
PASS
4S
5M
5P
...

output:

A IN 1M
B IN DOUBLE
C IN 3S
D IN 9P
A IN 6S
B IN 3M
C IN S
D IN 6P
A IN 2S
B IN 7S
C IN 1S
D IN 6M
A IN 5M
B IN 3S
C IN 7S
D IN 9M
A IN 2P
B IN 6M
C IN F
D IN 6P
A IN 5M
B IN 3P
C IN 9S
D IN E
A IN 2M
B IN 9P
C IN 6P
D IN 5P
A IN S
B IN S
C IN 8P
D IN B
A IN W
B IN 1M
C IN S
D IN F
A IN 5S
B IN PASS...

result:

ok 125 lines

Test #36:

score: 0
Accepted
time: 233ms
memory: 89524kb

input:

4M
5S
W
Z
6M
8P
E
7S
8P
4S
7P
W
7P
F
DOUBLE
3P
7S
6M
2P
4P
DOUBLE
1S
4M
8S
3S
8P
6M
3P
W
7M
2S
W
5M
REVERSE
5M
1S
3M
7M
1P
S
PASS
3S
4M
7S
3M
3S
4P
N
S
6S
PASS
2M
9S
1M
9P
F
REVERSE
6P
Z
F
5P
4S
6S
6S
7M
2S
DOUBLE
B
5S
9P
8P
6P
8M
9P
9S
9M
2M
N
4P
Z
5M
B
PASS
1M
4P
B
1P
5P
9M
1S
Z
REVERSE
7S
1P
8S
5...

output:

A IN 4M
B IN 5S
C IN W
D IN Z
A IN 6M
B IN 8P
C IN E
D IN 7S
A IN 8P
B IN 4S
C IN 7P
D IN W
A IN 7P
B IN F
C IN DOUBLE
D IN 3P
A IN 7S
B IN 6M
C IN 2P
D IN 4P
A IN DOUBLE
B IN 1S
C IN 4M
D IN 8S
A IN 3S
B IN 8P
C IN 6M
D IN 3P
A IN W
B IN 7M
C IN 2S
D IN W
A IN 5M
B IN REVERSE
C IN 5M
D IN 1S
A IN 3...

result:

ok 132 lines

Test #37:

score: 0
Accepted
time: 211ms
memory: 89680kb

input:

1S
8P
1M
7S
2P
3M
7P
PASS
3P
5M
6P
2P
REVERSE
2P
5S
S
5M
7M
6P
1M
6S
7M
2S
9P
REVERSE
9M
9S
1S
3P
N
PASS
PASS
8S
B
7M
9P
1P
2S
REVERSE
5P
DOUBLE
2S
9M
1M
6S
8M
8M
6M
7M
3S
2P
1S
8S
N
DOUBLE
8P
F
S
5M
4P
S
4S
REVERSE
2M
5S
Z
3S
W
Z
E
9S
7P
F
1S
3S
9S
7S
Z
W
2M
9S
5P
2M
3S
8P
W
6M
8S
4P
5P
4P
8S
8M
1P...

output:

A IN 1S
B IN 8P
C IN 1M
D IN 7S
A IN 2P
B IN 3M
C IN 7P
D IN PASS
A IN 3P
B IN 5M
C IN 6P
D IN 2P
A IN REVERSE
B IN 2P
C IN 5S
D IN S
A IN 5M
B IN 7M
C IN 6P
D IN 1M
A IN 6S
B IN 7M
C IN 2S
D IN 9P
A IN REVERSE
B IN 9M
C IN 9S
D IN 1S
A IN 3P
B IN N
C IN PASS
D IN PASS
A IN 8S
B IN B
C IN 7M
D IN 9P...

result:

ok 154 lines

Test #38:

score: 0
Accepted
time: 204ms
memory: 89668kb

input:

8P
6P
9S
8M
1P
N
F
5P
7P
2P
DOUBLE
6M
5M
REVERSE
2P
5S
S
7S
6S
6P
3S
2M
W
3P
8S
REVERSE
5P
4M
Z
2M
6P
4M
8M
9M
4S
1M
W
1S
9P
8P
4S
3P
6S
1P
N
B
5S
Z
3S
1M
3M
1P
5M
7P
N
5P
7M
9S
PASS
B
5M
7M
1S
6S
6S
9P
E
PASS
6M
2S
2M
PASS
1M
E
7M
7P
9M
5P
F
1S
9P
6M
4P
B
4S
2S
8P
9M
2S
9S
9P
3P
S
8S
5S
Z
F
7S
2P
P...

output:

A IN 8P
B IN 6P
C IN 9S
D IN 8M
A IN 1P
B IN N
C IN F
D IN 5P
A IN 7P
B IN 2P
C IN DOUBLE
D IN 6M
A IN 5M
B IN REVERSE
C IN 2P
D IN 5S
A IN S
B IN 7S
C IN 6S
D IN 6P
A IN 3S
B IN 2M
C IN W
D IN 3P
A IN 8S
B IN REVERSE
C IN 5P
D IN 4M
A IN Z
B IN 2M
C IN 6P
D IN 4M
A IN 8M
B IN 9M
C IN 4S
D IN 1M
A I...

result:

ok 166 lines

Test #39:

score: 0
Accepted
time: 225ms
memory: 89668kb

input:

3M
1P
9M
W
W
3M
DOUBLE
9M
1P
3M
4S
5S
REVERSE
7S
2S
2P
1M
3P
3M
4M
B
N
Z
4P
S
REVERSE
7M
8P
7P
F
N
PASS
6M
W
9S
E
3P
6P
E
7P
F
7M
3P
DOUBLE
5P
8P
8S
7S
6P
8P
7M
8M
8M
9P
1M
1S
2M
Z
PASS
7P
5M
5S
4P
9S
3P
4S
W
4P
3S
B
2P
7S
6M
F
5M
E
2S
REVERSE
9M
N
2S
1S
7P
2M
8S
6M
6M
REVERSE
8S
5M
5S
Z
4S
B
2P
9P
...

output:

A IN 3M
B IN 1P
C IN 9M
D IN W
A IN W
B IN 3M
C IN DOUBLE
D IN 9M
A IN 1P
B IN 3M
C IN 4S
D IN 5S
A IN REVERSE
B IN 7S
C IN 2S
D IN 2P
A IN 1M
B IN 3P
C IN 3M
D IN 4M
A IN B
B IN N
C IN Z
D IN 4P
A IN S
B IN REVERSE
C IN 7M
D IN 8P
A IN 7P
B IN F
C IN N
D IN PASS
A IN 6M
B IN W
C IN 9S
D IN E
A IN 3...

result:

ok 154 lines

Test #40:

score: 0
Accepted
time: 200ms
memory: 89572kb

input:

8S
7P
4P
DOUBLE
3S
8P
6P
7M
1S
4P
5P
8M
B
5M
6M
REVERSE
6P
1P
9M
9M
1M
PASS
3P
2S
N
E
Z
1M
9S
7P
F
W
6M
5S
3M
1P
E
3M
9P
2P
4P
6S
8M
1P
6P
2S
9P
W
REVERSE
DOUBLE
5S
4M
7S
9P
S
B
9M
7M
S
S
3S
6S
9P
5M
N
5P
6P
2P
E
2M
F
6M
5M
4M
8P
PASS
Z
DOUBLE
7S
3M
7S
3S
4M
REVERSE
9S
9M
3P
3S
F
F
4S
1S
3P
5P
7P
W
...

output:

A IN 8S
B IN 7P
C IN 4P
D IN DOUBLE
A IN 3S
B IN 8P
C IN 6P
D IN 7M
A IN 1S
B IN 4P
C IN 5P
D IN 8M
A IN B
B IN 5M
C IN 6M
D IN REVERSE
A IN 6P
B IN 1P
C IN 9M
D IN 9M
A IN 1M
B IN PASS
C IN 3P
D IN 2S
A IN N
B IN E
C IN Z
D IN 1M
A IN 9S
B IN 7P
C IN F
D IN W
A IN 6M
B IN 5S
C IN 3M
D IN 1P
A IN E
...

result:

ok 152 lines

Test #41:

score: 0
Accepted
time: 198ms
memory: 89664kb

input:

Z
8S
F
4M
5S
6S
6P
9S
2P
1P
9M
F
4P
4M
5P
2S
5S
3S
9M
Z
DOUBLE
7P
8P
2P
9P
DOUBLE
5P
W
1P
7M
7S
6S
PASS
7P
N
5M
8S
6P
1P
REVERSE
1M
B
4P
N
6S
9P
6M
9P
7P
3M
3M
4P
8M
7M
2S
4S
6M
8M
1M
3S
6M
8P
PASS
1S
REVERSE
N
3S
3P
4S
7M
1S
F
DOUBLE
7M
2M
2S
W
5P
2P
W
PASS
7S
8S
6S
E
PASS
2S
2P
Z
3P
E
6M
S
REVERSE...

output:

A IN Z
B IN 8S
C IN F
D IN 4M
A IN 5S
B IN 6S
C IN 6P
D IN 9S
A IN 2P
B IN 1P
C IN 9M
D IN F
A IN 4P
B IN 4M
C IN 5P
D IN 2S
A IN 5S
B IN 3S
C IN 9M
D IN Z
A IN DOUBLE
B IN 7P
C IN 8P
D IN 2P
A IN 9P
B IN DOUBLE
C IN 5P
D IN W
A IN 1P
B IN 7M
C IN 7S
D IN 6S
A IN PASS
B IN 7P
C IN N
D IN 5M
A IN 8S
...

result:

ok 183 lines

Test #42:

score: 0
Accepted
time: 208ms
memory: 89600kb

input:

7S
4P
B
B
1S
Z
PASS
3S
6P
1P
PASS
REVERSE
7M
8M
1M
5M
F
1M
6M
DOUBLE
9M
3P
3M
3S
9S
5P
DOUBLE
9P
1P
REVERSE
2M
8S
8S
4M
8P
S
E
PASS
PASS
7P
9S
3P
W
4S
6P
6S
9S
8M
8P
1P
B
3M
9P
1S
5M
4S
F
Z
2P
5S
6M
3S
2S
5P
2S
DOUBLE
9M
REVERSE
4M
8S
4S
7S
2S
5P
N
1M
4P
5M
DOUBLE
4S
5S
7M
S
N
6S
7S
Z
E
3M
1S
S
6S
2...

output:

A IN 7S
B IN 4P
C IN B
D IN B
A IN 1S
B IN Z
C IN PASS
D IN 3S
A IN 6P
B IN 1P
C IN PASS
D IN REVERSE
A IN 7M
B IN 8M
C IN 1M
D IN 5M
A IN F
B IN 1M
C IN 6M
D IN DOUBLE
A IN 9M
B IN 3P
C IN 3M
D IN 3S
A IN 9S
B IN 5P
C IN DOUBLE
D IN 9P
A IN 1P
B IN REVERSE
C IN 2M
D IN 8S
A IN 8S
B IN 4M
C IN 8P
D ...

result:

ok 204 lines

Test #43:

score: 0
Accepted
time: 200ms
memory: 89624kb

input:

9P
REVERSE
S
3M
1S
2S
7S
1M
F
PASS
B
Z
5S
2P
9S
4P
8P
9P
3P
1P
4P
9P
8P
B
N
DOUBLE
E
PASS
9M
REVERSE
5M
N
9S
7M
S
4P
8S
N
3P
2P
3S
9S
8S
7S
3M
Z
5P
4S
DOUBLE
6P
9S
3P
DOUBLE
6M
1P
9M
F
8S
1P
2M
4P
1S
DOUBLE
REVERSE
Z
S
5S
6S
6M
7M
2S
5M
5P
2P
7P
6M
6S
4M
5P
2S
1M
6P
5S
9M
1M
6S
E
3S
3M
1S
7M
W
8P
W
...

output:

A IN 9P
B IN REVERSE
C IN S
D IN 3M
A IN 1S
B IN 2S
C IN 7S
D IN 1M
A IN F
B IN PASS
C IN B
D IN Z
A IN 5S
B IN 2P
C IN 9S
D IN 4P
A IN 8P
B IN 9P
C IN 3P
D IN 1P
A IN 4P
B IN 9P
C IN 8P
D IN B
A IN N
B IN DOUBLE
C IN E
D IN PASS
A IN 9M
B IN REVERSE
C IN 5M
D IN N
A IN 9S
B IN 7M
C IN S
D IN 4P
A I...

result:

ok 184 lines

Test #44:

score: 0
Accepted
time: 203ms
memory: 89628kb

input:

9M
S
5S
6P
7M
7S
3M
8S
N
DOUBLE
5P
E
4M
7P
9M
1S
Z
4P
1P
4P
8P
PASS
B
N
7P
8M
7P
3S
8P
2P
7S
5P
9M
5S
S
2S
8P
S
N
3S
F
7M
2S
6P
3M
REVERSE
8S
3S
REVERSE
9S
2S
3P
6M
3M
S
6P
6M
E
F
2M
5P
B
PASS
7M
3P
7S
6P
F
1M
8P
5S
PASS
5M
Z
6S
DOUBLE
1S
7S
2S
5S
PASS
1M
6S
9P
7P
1P
9P
2M
1S
1M
2P
2P
6M
3S
4S
8S
3P...

output:

A IN 9M
B IN S
C IN 5S
D IN 6P
A IN 7M
B IN 7S
C IN 3M
D IN 8S
A IN N
B IN DOUBLE
C IN 5P
D IN E
A IN 4M
B IN 7P
C IN 9M
D IN 1S
A IN Z
B IN 4P
C IN 1P
D IN 4P
A IN 8P
B IN PASS
C IN B
D IN N
A IN 7P
B IN 8M
C IN 7P
D IN 3S
A IN 8P
B IN 2P
C IN 7S
D IN 5P
A IN 9M
B IN 5S
C IN S
D IN 2S
A IN 8P
B IN ...

result:

ok 158 lines

Test #45:

score: 0
Accepted
time: 202ms
memory: 89676kb

input:

2M
4S
DOUBLE
W
B
2P
N
9P
F
S
4S
3P
6P
9M
6S
1S
3S
4M
9P
N
W
REVERSE
7M
6S
9S
7S
F
REVERSE
E
4P
8P
5M
3S
Z
4P
4M
2S
7M
3P
7S
S
8S
1S
6P
5P
5P
5M
B
3P
9S
9M
PASS
4S
1S
6M
2S
6P
1M
REVERSE
8M
S
E
5M
S
2M
9M
9P
B
7S
6S
8S
REVERSE
1P
F
PASS
9P
DOUBLE
E
Z
7M
8M
2S
2S
6M
5S
7P
2P
2M
6M
3M
PASS
5S
W
7P
9S
8...

output:

A IN 2M
B IN 4S
C IN DOUBLE
D IN W
A IN B
B IN 2P
C IN N
D IN 9P
A IN F
B IN S
C IN 4S
D IN 3P
A IN 6P
B IN 9M
C IN 6S
D IN 1S
A IN 3S
B IN 4M
C IN 9P
D IN N
A IN W
B IN REVERSE
C IN 7M
D IN 6S
A IN 9S
B IN 7S
C IN F
D IN REVERSE
A IN E
B IN 4P
C IN 8P
D IN 5M
A IN 3S
B IN Z
C IN 4P
D IN 4M
A IN 2S
...

result:

ok 181 lines

Test #46:

score: 0
Accepted
time: 198ms
memory: 89500kb

input:

8P
4P
1M
1M
5P
2S
8S
9P
1M
7P
8S
8M
2P
5P
N
B
DOUBLE
REVERSE
S
F
6M
2P
PASS
6S
DOUBLE
3M
B
4S
2S
5P
9P
8P
7P
6P
9P
7S
5S
4P
Z
3M
9S
3S
5M
8S
DOUBLE
F
1P
PASS
4M
N
E
E
E
4P
6M
3M
4M
4S
3S
2M
9S
4M
6M
F
N
8M
PASS
7M
8P
6S
1S
7S
Z
9M
B
7P
7M
1S
7S
S
6M
2M
1P
4S
4S
W
3M
DOUBLE
8S
2M
7S
8M
N
1P
6P
B
2M
W...

output:

A IN 8P
B IN 4P
C IN 1M
D IN 1M
A IN 5P
B IN 2S
C IN 8S
D IN 9P
A IN 1M
B IN 7P
C IN 8S
D IN 8M
A IN 2P
B IN 5P
C IN N
D IN B
A IN DOUBLE
B IN REVERSE
C IN S
D IN F
A IN 6M
B IN 2P
C IN PASS
D IN 6S
A IN DOUBLE
B IN 3M
C IN B
D IN 4S
A IN 2S
B IN 5P
C IN 9P
D IN 8P
A IN 7P
B IN 6P
C IN 9P
D IN 7S
A ...

result:

ok 153 lines

Test #47:

score: 0
Accepted
time: 197ms
memory: 89468kb

input:

E
8S
E
N
8S
2M
PASS
Z
2P
5P
W
PASS
2S
8P
4S
2P
N
1P
5P
F
B
7S
4S
4S
5S
6P
4M
B
3S
5M
7M
7M
Z
4S
1M
PASS
5P
B
1S
1S
6S
F
W
6M
REVERSE
PASS
2S
5M
DOUBLE
6P
7P
9P
6S
DOUBLE
N
8P
1S
F
1S
3P
REVERSE
8S
4M
9M
9S
2M
W
1P
7S
3M
9M
7M
9P
9M
7M
1M
E
S
5S
3P
S
8M
2M
DOUBLE
B
9P
2M
6S
8P
8M
9S
1P
6M
W
E
7P
1M
9...

output:

A IN E
B IN 8S
C IN E
D IN N
A IN 8S
B IN 2M
C IN PASS
D IN Z
A IN 2P
B IN 5P
C IN W
D IN PASS
A IN 2S
B IN 8P
C IN 4S
D IN 2P
A IN N
B IN 1P
C IN 5P
D IN F
A IN B
B IN 7S
C IN 4S
D IN 4S
A IN 5S
B IN 6P
C IN 4M
D IN B
A IN 3S
B IN 5M
C IN 7M
D IN 7M
A IN Z
B IN 4S
C IN 1M
D IN PASS
A IN 5P
B IN B
C...

result:

ok 164 lines

Test #48:

score: 0
Accepted
time: 209ms
memory: 89572kb

input:

E
E
5S
N
8M
PASS
Z
PASS
2P
REVERSE
2M
2M
4M
5S
1M
7P
9M
5S
9P
N
4P
8M
1S
9S
6M
8S
7P
5M
F
4P
3M
6P
3S
4S
W
DOUBLE
7P
9M
B
7P
8P
3P
3S
S
2M
5P
DOUBLE
4P
3P
S
1P
B
4S
8S
9S
2S
1P
1P
8S
REVERSE
3P
3M
3S
DOUBLE
9M
B
9S
5M
W
2P
2P
6M
7M
Z
4M
2M
2S
1S
3P
3M
S
4S
8M
F
1S
7M
4M
2S
4S
6M
6P
9M
9P
2S
6S
Z
7S
...

output:

A IN E
B IN E
C IN 5S
D IN N
A IN 8M
B IN PASS
C IN Z
D IN PASS
A IN 2P
B IN REVERSE
C IN 2M
D IN 2M
A IN 4M
B IN 5S
C IN 1M
D IN 7P
A IN 9M
B IN 5S
C IN 9P
D IN N
A IN 4P
B IN 8M
C IN 1S
D IN 9S
A IN 6M
B IN 8S
C IN 7P
D IN 5M
A IN F
B IN 4P
C IN 3M
D IN 6P
A IN 3S
B IN 4S
C IN W
D IN DOUBLE
A IN 7...

result:

ok 125 lines

Test #49:

score: 0
Accepted
time: 199ms
memory: 89536kb

input:

S
8P
4S
8S
3M
5P
9M
5S
4P
4M
5P
3P
2S
8M
1S
7P
3M
7P
9S
S
W
1S
1S
5P
F
7M
4S
N
9M
5S
9M
1M
6P
6M
8S
4P
1M
3S
5M
6P
PASS
1M
3P
5S
N
6S
5M
9M
B
Z
6M
1P
DOUBLE
4M
5M
7M
7S
9S
7S
S
7P
3S
DOUBLE
2P
7M
B
2P
9P
7S
6S
B
3P
2M
Z
E
7S
8M
8P
W
DOUBLE
F
8M
8P
1S
7M
5M
Z
6M
B
2S
PASS
2M
DOUBLE
6S
6S
N
F
6P
E
REV...

output:

A IN S
B IN 8P
C IN 4S
D IN 8S
A IN 3M
B IN 5P
C IN 9M
D IN 5S
A IN 4P
B IN 4M
C IN 5P
D IN 3P
A IN 2S
B IN 8M
C IN 1S
D IN 7P
A IN 3M
B IN 7P
C IN 9S
D IN S
A IN W
B IN 1S
C IN 1S
D IN 5P
A IN F
B IN 7M
C IN 4S
D IN N
A IN 9M
B IN 5S
C IN 9M
D IN 1M
A IN 6P
B IN 6M
C IN 8S
D IN 4P
A IN 1M
B IN 3S
C...

result:

ok 172 lines

Test #50:

score: 0
Accepted
time: 201ms
memory: 89604kb

input:

Z
9M
7S
PASS
S
9S
6S
1S
2S
9S
6M
N
W
F
5P
W
9S
REVERSE
9P
3P
4M
7P
7M
5M
1S
8P
S
5M
6M
1P
2P
4P
3M
1S
REVERSE
5P
9P
B
4M
2S
4S
REVERSE
5S
8M
3M
5P
6S
3S
8S
8M
8P
8M
PASS
4P
6M
6P
2S
Z
8P
4M
6P
Z
1M
2M
E
6M
7P
7M
1S
4S
2P
DOUBLE
1M
1M
9S
W
3P
2S
N
3S
7M
B
7P
9M
B
N
8S
3S
DOUBLE
REVERSE
4S
7M
6S
5P
E
...

output:

A IN Z
B IN 9M
C IN 7S
D IN PASS
A IN S
B IN 9S
C IN 6S
D IN 1S
A IN 2S
B IN 9S
C IN 6M
D IN N
A IN W
B IN F
C IN 5P
D IN W
A IN 9S
B IN REVERSE
C IN 9P
D IN 3P
A IN 4M
B IN 7P
C IN 7M
D IN 5M
A IN 1S
B IN 8P
C IN S
D IN 5M
A IN 6M
B IN 1P
C IN 2P
D IN 4P
A IN 3M
B IN 1S
C IN REVERSE
D IN 5P
A IN 9P...

result:

ok 156 lines