QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#282699#2894. 麻将模拟器qkm66666AC ✓178ms4088kbC++149.8kb2023-12-12 19:54:432023-12-12 19:54:43

Judging History

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

  • [2023-12-12 19:54:43]
  • 评测
  • 测评结果:AC
  • 用时:178ms
  • 内存:4088kb
  • [2023-12-12 19:54:43]
  • 提交

answer

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<vector>
#include<bitset>
#include<random>
#include<ctime>
#include<queue>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long,long long>
#define FF fflush(stdout)
#define inf 0x3f3f3f3f
#define endl "\n"
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
//char buf[1<<20],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline int read()
{
    int s=0,f=1;
    char x=getchar();
    while(!isdigit(x))f=(x=='-'?-1:1),x=getchar();
    while(isdigit(x))s=s*10+x-'0',x=getchar();
    return s*f;
}
const int p=1e9+7;
//ll ksm(int a,int b){ll ans=1,bs=a;while(b){if(b&1)ans=ans*bs%p;bs=bs*bs%p;b>>=1;}return ans;}
mt19937 rd(time(0));
#define reaD read
int c[555];
int cur[555];
int ans;
bool ok=1;
void era(vector<int> &a,int x)
{
    for(int i=0;i<a.size();i++)
    {
        if(a[i]==x)
        {
            a.erase(a.begin()+i);
            break;
        }
    }
}
void dfs(vector<int> a,int s,int d,int cs)
{
    if(cs>=ans)return ;
    ans=min(ans,cs+s*3);
    if(s==0)
    {
        // ans=min(ans,cs);
        return ;
    }
    for(int i=max(0,d);i<a.size();i++)
    if(i==a.size()-1||a[i]!=a[i+1])
    {
        if(a[i]>500)return ;
        vector<int> tmp=a;
        if(a[i]<400&&cur[a[i]+1]&&cur[a[i]+2])
        {
            tmp=a;
            era(tmp,a[i]);
            era(tmp,a[i]+1);
            era(tmp,a[i]+2);
            cur[a[i]]--;
            cur[a[i]+2]--;
            cur[a[i]+1]--;
            dfs(tmp,s-1,i-1,cs);
            cur[a[i]]++;
            cur[a[i]+2]++;
            cur[a[i]+1]++;
        }
        if(cur[a[i]]>=3)
        {
            tmp=a;
            era(tmp,a[i]);
            era(tmp,a[i]);
            era(tmp,a[i]);
            cur[a[i]]-=3;
            dfs(tmp,s-1,i-3,cs);
            cur[a[i]]+=3;
        }
        if(cur[a[i]]==2&&c[a[i]]<=3)
        {
            tmp=a;
            era(tmp,a[i]);
            era(tmp,a[i]);
            cur[a[i]]-=2;
            c[a[i]]++;
            dfs(tmp,s-1,i-2,cs+1);
            c[a[i]]--;
            cur[a[i]]+=2;
        }
        if(a[i]<400&&cur[a[i]+1])
        {
            if(a[i]%10<=7&&c[a[i]+2]<=3&&!cur[a[i]+2])
            {
                tmp=a;
                era(tmp,a[i]);
                era(tmp,a[i]+1);
                cur[a[i]]--;
                cur[a[i]+1]--;
                c[a[i]+2]++;
                dfs(tmp,s-1,i-1,cs+1);
                cur[a[i]]++;
                cur[a[i]+1]++;
                c[a[i]+2]--;
            }
            if(a[i]%10<=8&&a[i]%10>=2&&c[a[i]-1]<=3&&!cur[a[i]-1])
            {
                tmp=a;
                era(tmp,a[i]);
                era(tmp,a[i]+1);
                cur[a[i]]--;
                cur[a[i]+1]--;
                c[a[i]-1]++;
                dfs(tmp,s-1,i-1,cs+1);
                cur[a[i]]++;
                cur[a[i]+1]++;
                c[a[i]-1]--;
            }
        }
        if(a[i]<400&&cur[a[i]+2])
        {
            if(c[a[i]+1]<=3&&!cur[a[i]+1])
            {
                tmp=a;
                era(tmp,a[i]);
                era(tmp,a[i]+2);
                cur[a[i]]--;
                cur[a[i]+2]--;
                c[a[i]+1]++;
                dfs(tmp,s-1,i-1,cs+1);
                cur[a[i]]++;
                cur[a[i]+2]++;
                c[a[i]+1]--;
            }
        }

        era(tmp,a[i]);
        if(c[a[i]]<=2&&cur[a[i]]==1)
        cur[a[i]]--,c[a[i]]+=2,dfs(tmp,s-1,i-1,cs+2),c[a[i]]-=2,cur[a[i]]++;
        if(a[i]<400&&a[i]%10<=7&&c[a[i]+1]<=3&&c[a[i]+2]<=3&&!cur[a[i]+1]&&!cur[a[i]+2])
        cur[a[i]]--,c[a[i]+1]++,c[a[i]+2]++,dfs(tmp,s-1,i-1,cs+2),c[a[i]+1]--,c[a[i]+2]--,cur[a[i]]++;
        if(a[i]<400&&a[i]%10<=8&&a[i]%10>=2&&c[a[i]-1]<=3&&c[a[i]+1]<=3&&!cur[a[i]-1]&&!cur[a[i]+1])
        cur[a[i]]--,c[a[i]-1]++,c[a[i]+1]++,dfs(tmp,s-1,i-1,cs+2),c[a[i]-1]--,c[a[i]+1]--,cur[a[i]]++;
        if(a[i]<400&&a[i]%10>=3&&c[a[i]-1]<=3&&c[a[i]-2]<=3&&!cur[a[i]-1]&&!cur[a[i]-2])
        cur[a[i]]--,c[a[i]-1]++,c[a[i]-2]++,dfs(tmp,s-1,i-1,cs+2),c[a[i]-1]--,c[a[i]-2]--,cur[a[i]]++;
   
    }
}
int cal(vector<int> a)
{
    for(auto i:a)c[i]++,cur[i]++;
    ans=a.size()/3*2+1;
    for(int i=0;i<a.size();i++)
    if(i==0||a[i]!=a[i-1])
    {
        vector<int> tmp=a;
        if(cur[a[i]]>=2)
        {
            era(tmp,a[i]);
            era(tmp,a[i]);
            cur[a[i]]-=2;
            dfs(tmp,a.size()/3,0,0);
            cur[a[i]]+=2;
        }
        if(c[a[i]]<=3)
        {
            tmp=a;
            era(tmp,a[i]);
            cur[a[i]]--;
            c[a[i]]++;
            dfs(tmp,a.size()/3,0,1);
            cur[a[i]]++;
            c[a[i]]--;
        }
    }
    // dfs(a,a.size()/3,0,1);
    for(auto i:a)c[i]--,cur[i]--;
    return ans;
}
int pile[155];
int tp=1;
int ID[312];
int ID2[312];
vector<int> a[4],b[4];
int now,turn=1;
char nam[555][13];
int card;
bool use;
void mo()
{
    printf("%c IN %s\n",now+'A',nam[pile[tp]]);
    a[now].pb(pile[tp++]);
    sort(a[now].begin(),a[now].end());
}
void out(int x)
{
    card=a[now][x];
    use=0;
    if(card==503)
    printf("%c OUT %s %c\n",now+'A',nam[card],(now+turn+4)%4+'A');
    else
    printf("%c OUT %s\n",now+'A',nam[card]);
    a[now].erase(a[now].begin()+x);
}
int nxt(int now)
{
    return (now+turn+4)%4;
}
void ckzm()
{
    if(cal(a[now])==0)
    {
        printf("%c SELFDRAWN\n%c WIN\n",now+'A',now+'A');
        // system("pause");
        exit(0);
    }
}
void ckron(int x)
{
    vector<int> tmp=a[x];
    tmp.pb(card);
    sort(tmp.begin(),tmp.end());
    if(cal(tmp)==0)
    {
        printf("%c RON\n%c WIN\n",x+'A',x+'A');
        // system("pause");
        exit(0);
    }
}
void pon(int x)
{
    printf("%c PONG %s %s %s\n",x+'A',nam[card],nam[card],nam[card]);
    era(a[x],card);
    era(a[x],card);
    now=x;
    use=1;
    ok=0;
}
void chow(int x,int ca,int cb,int cc)
{
    printf("%c CHOW %s %s %s\n",x+'A',nam[ca],nam[cb],nam[cc]);
    if(ca!=card)era(a[x],ca);
    if(cb!=card)era(a[x],cb);
    if(cc!=card)era(a[x],cc);
    now=x;
    use=1;
    ok=0;
}
void ckpon(int x)
{
    if(use)return ;
    int cnt=0;
    for(auto i:a[x])
    if(i==card)cnt++;
    if(cnt<=1)return ;
    cnt=0;
    vector<int> tmp;
    for(auto i:a[x])
    {
        if(i==card)
        {
            if(cnt==2)tmp.pb(i);
            else cnt++;
        }
        else tmp.pb(i);
    }
    if(cal(tmp)<cal(a[x]))pon(x);
    return ;
}
int ch[555];
void ckchow(int x)
{
    if(use||card>400)return ;
    for(auto i:a[x])
    ch[i]++;
    vector<int> las=a[x];
    int ori=cal(a[x]);
    if(ch[card+1]&&ch[card+2])
    {
        vector<int> tmp=a[x];
        era(tmp,card+1);
        era(tmp,card+2);
        if(cal(tmp)<ori)
        chow(x,card,card+1,card+2);
    }
    if(!use&&ch[card-1]&&ch[card+1])
    {
        vector<int> tmp=a[x];
        era(tmp,card-1);
        era(tmp,card+1);
        if(cal(tmp)<ori)
        chow(x,card-1,card,card+1);
    }
    if(!use&&ch[card-2]&&ch[card-1])
    {
        vector<int> tmp=a[x];
        era(tmp,card-2);
        era(tmp,card-1);
        if(cal(tmp)<ori)
        chow(x,card-2,card-1,card);
    }
    for(auto i:las)
    ch[i]--;
}
void dbg()
{
    printf("now: %c\n",now+'A');
    for(int i=0;i<=3;i++)
    {
        printf("card of %c: ",i+'A');
        for(auto j:a[i])
        printf("%s ",nam[j]);puts("");
        // printf("xiangting: %d\n",cal(a[i]));
    }
    for(int i=1;i<=505;i++)
    assert(c[i]==0&&cur[i]==0&&ch[i]==0);
}
int main()
{
    ID['E']=401,ID['S']=402,ID['W']=403,ID['N']=404,ID['B']=405,ID['F']=406,ID['Z']=407;
    ID2['M']=100,ID2['P']=200,ID2['S']=300;
    nam[401][0]='E',nam[402][0]='S',nam[403][0]='W',nam[404][0]='N',nam[405][0]='B',nam[406][0]='F',nam[407][0]='Z';
    for(int i=1;i<=3;i++)
    for(int j=1;j<=9;j++)
    nam[i*100+j][0]='0'+j,nam[i*100+j][1]=(i==1?'M':(i==2?'P':'S'));
    strcpy(nam[503],"PASS");
    strcpy(nam[502],"REVERSE");
    strcpy(nam[501],"DOUBLE");
    for(int i=1;i<=148;i++)
    {
        string s;
        cin>>s;
        if(s.size()>3)
        {
            if(s[0]=='P')pile[i]=503;
            if(s[0]=='R')pile[i]=502;
            if(s[0]=='D')pile[i]=501;
        }
        else if(s.size()==1)
        {
            pile[i]=ID[s[0]];
        }
        else pile[i]=ID2[s[1]]+s[0]-'0';
    }
    for(int i=1;i<=52;i++)
    {
        mo();
        now=nxt(now);
    }
    for(int i=0;i<=3;i++)
    sort(a[i].begin(),a[i].end());
    while(tp<=148)
    {
        if(ok)mo();
        // dbg();
        if(a[now].back()>500)
        {
            out(a[now].size()-1);
            if(card==503)now=(now+turn*2+4)%4;
            if(card==502)turn*=-1,now=nxt(now);
            ok=1;
            continue;
        }
        ckzm();
        int ori=cal(a[now]);
        for(int i=a[now].size()-1;i>=0;i--)
        {
            vector<int> tmp=a[now];
            tmp.erase(tmp.begin()+i);
            // cout<<cal(tmp)<<" ";
            if(cal(tmp)==ori)
            {
                out(i);
                break;
            }
        }
        for(int i=1,j=nxt(now);i<=3&&!use;i++,j=nxt(j))
        ckron(j);
        for(int i=1,j=nxt(now);i<=3&&!use;i++,j=nxt(j))
        ckpon(j);
        ckchow(nxt(now));
        if(!use)now=nxt(now),ok=1;
    }
    puts("DRAW");
    // system("pause");
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 27ms
memory: 3856kb

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: 123ms
memory: 3888kb

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: 52ms
memory: 3808kb

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: 136ms
memory: 4040kb

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: 33ms
memory: 4016kb

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: 63ms
memory: 3804kb

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: 150ms
memory: 4016kb

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: 23ms
memory: 3800kb

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: 73ms
memory: 3892kb

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: 41ms
memory: 4084kb

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: 67ms
memory: 3792kb

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: 87ms
memory: 4088kb

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: 91ms
memory: 3856kb

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: 138ms
memory: 3896kb

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: 169ms
memory: 4012kb

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: 95ms
memory: 4016kb

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: 108ms
memory: 3800kb

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: 133ms
memory: 4040kb

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: 120ms
memory: 3860kb

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: 147ms
memory: 4008kb

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: 78ms
memory: 4008kb

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: 131ms
memory: 4040kb

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: 116ms
memory: 4012kb

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: 46ms
memory: 4020kb

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: 89ms
memory: 3856kb

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: 87ms
memory: 3800kb

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: 97ms
memory: 3832kb

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: 98ms
memory: 3788kb

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: 109ms
memory: 3788kb

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: 89ms
memory: 4012kb

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: 56ms
memory: 3836kb

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: 87ms
memory: 3808kb

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: 85ms
memory: 4040kb

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: 83ms
memory: 3812kb

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: 102ms
memory: 3792kb

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: 66ms
memory: 3792kb

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: 120ms
memory: 3828kb

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: 123ms
memory: 4084kb

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: 81ms
memory: 3832kb

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: 64ms
memory: 3832kb

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: 102ms
memory: 4016kb

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: 137ms
memory: 3800kb

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: 83ms
memory: 3744kb

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: 51ms
memory: 3804kb

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: 178ms
memory: 4016kb

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: 138ms
memory: 3860kb

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: 115ms
memory: 3832kb

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: 58ms
memory: 3756kb

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: 150ms
memory: 4020kb

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: 55ms
memory: 3780kb

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