#include <bits/stdc++.h>
using namespace std;
map<string,pair<double,double> > m;
int n,q,k;
struct node{
string a,b,c,d;
}a[35];
map<string,int> m1;
map<string,int> m2;
string paidui[300010];
int main(){
freopen("ex3.in","r",stdin);
m["A1"]=make_pair(1,1);
m["A2"]=make_pair(1,2);
m["A5"]=make_pair(1,5);
m["A9"]=make_pair(1,9);
m["A19"]=make_pair(1,19);
m["A49"]=make_pair(1,49);
m["A99"]=make_pair(1,99);
m["B1"]=make_pair(1,-1);
m["B9"]=make_pair(1,-9);
m["B19"]=make_pair(1,-19);
m["C2"]=make_pair(2,0);
m["D2"]=make_pair(0.5,0);
m["E0"]=make_pair(0,0);
m["E49"]=make_pair(0,49);
m["E99"]=make_pair(0,99);
m1["A1"]=2;
m1["A2"]=2;
m1["A5"]=2;
m1["A9"]=2;
m1["A19"]=2;
m1["A49"]=2;
m1["A99"]=2;
m1["B1"]=3;
m1["B9"]=3;
m1["B19"]=3;
m1["C2"]=1;
m1["D2"]=4;
m1["E0"]=5;
m1["E49"]=5;
m1["E99"]=5;
m2["A1"]=3;
m2["A2"]=3;
m2["A5"]=3;
m2["A9"]=3;
m2["A19"]=3;
m2["A49"]=3;
m2["A99"]=3;
m2["B1"]=2;
m2["B9"]=2;
m2["B19"]=2;
m2["C2"]=4;
m2["D2"]=1;
m2["E0"]=5;
m2["E49"]=5;
m2["E99"]=5;
cin>>n>>q>>k;
for(int i=1;i<=n;i++){
cin>>a[i].a>>a[i].b>>a[i].c>>a[i].d;
}
for(int i=1;i<=k;i++){
cin>>paidui[i];
}
int faild=1;
for(int i=1;i<=q;i++){
cout<<"Round "<<i<<":"<<endl;
double p=0;
int x=faild;
int fx=1;
bool flag=false;
int s=1;
while(true){
if(x>n){
x=1;
}
if(x<1){
x=n;
}
string a1=a[x].b;
string a2=a[x].c;
string a3=a[x].d;
string now;
if(flag){
if(a1=="PASS"||a2=="PASS"||a3=="PASS"){
bool c=false;
if(a1=="PASS"){
a[x].b=paidui[s];
s++;
c=true;
}
if(a2=="PASS"&&!c){
a[x].c=paidui[s];
s++;
c=true;
}
if(a3=="PASS"&&!c){
a[x].d=paidui[s];
s++;
c=true;
}
cout<<a[x].a<<" used PASS,now p="<<p<<"."<<endl;
x+=fx;
continue;
}else if(a1=="TURN"||a2=="TURN"||a3=="TURN"){
bool c=false;
if(a1=="TURN"){
a[x].b=paidui[s];
s++;
c=true;
}
if(a2=="TURN"&&!c){
a[x].c=paidui[s];
s++;
c=true;
}
if(a3=="TURN"&&!c){
a[x].d=paidui[s];
s++;
c=true;
}
cout<<a[x].a<<" used TURN,now p="<<p<<"."<<endl;
fx=-fx;
x+=fx;
continue;
}else if(a1=="DOUBLE"||a2=="DOUBLE"||a3=="DOUBLE"){
bool c=false;
if(a1=="DOUBLE"&&!c){
a[x].b=paidui[s];
s++;
c=true;
}
if(a2=="DOUBLE"&&!c){
a[x].c=paidui[s];
s++;
c=true;
}
if(a3=="DOUBLE"&&!c){
c=true;
a[x].d=paidui[s];
s++;
}
cout<<a[x].a<<" used DOUBLE,now p="<<p<<"."<<endl;
x+=fx;
flag=true;
continue;
}else{
double temp=p*m[a1].first+m[a1].second;
double temp1=p*m[a2].first+m[a2].second;
double temp2=p*m[a3].first+m[a3].second;
double min=999999;
temp=floor(temp);
temp1=floor(temp1);
temp2=floor(temp2);
if(temp<temp1){
min=temp;
now=a1;
}
if(temp==temp1){
min=temp;
if(m2[a1]<m2[a2]){
now=a1;
}else{
now=a2;
}
}
if(temp>temp1){
min=temp1;
now=a2;
}
if(min==temp2){
min=temp2;
if(m2[now]<m2[a3]){
now=now;
}else{
now=a3;
}
}
if(min>temp2){
min=temp2;
now=a3;
}
bool c=false;
if(now==a1){
a[x].b=paidui[s];
s++;
c=true;
}
if(now==a2&&!c){
a[x].c=paidui[s];
s++;
c=true;
}
if(now==a3&&!c){
c=true;
a[x].d=paidui[s];
s++;
}
p=min;
if(p>99){
cout<<a[x].a<<" lost the game."<<endl;
faild=x;
break;
}
flag=false;
}
}
if(!flag){
double temp=p*m[a1].first+m[a1].second;
double temp1=p*m[a2].first+m[a2].second;
double temp2=p*m[a3].first+m[a3].second;
temp=floor(temp);
temp1=floor(temp1);
temp2=floor(temp2);
if(a1=="PASS"||a1=="TURN"||a1=="DOUBLE"){
temp=-999999;
}
if(a2=="PASS"||a2=="TURN"||a2=="DOUBLE"){
temp1=-999999;
}
if(a3=="PASS"||a3=="TURN"||a3=="DOUBLE"){
temp2=-999999;
}
double max=-999999;
if(temp<temp1&&temp1<=99){
max=temp1;
now=a2;
}
if(temp1>99){
max=temp;
now=a1;
}
if(temp==temp1&&temp<=99){
max=temp;
if(m1[a1]<m1[a2]){
now=a1;
}else{
now=a2;
}
}
if(temp>temp1&&temp<=99){
max=temp;
now=a1;
}
if(temp>99){
max=temp1;
now=a2;
}
if(max<temp2&&temp2<=99){
max=temp2;
now=a3;
}
if(max==temp2&&temp2<=99){
max=temp2;
if(m1[now]<m1[a3]){
now=now;
}else{
now=a3;
}
}
bool c=false;
if(now==a1){
a[x].b=paidui[s];
s++;
c=true;
}
if(now==a2&&!c){
a[x].c=paidui[s];
s++;
c=true;
}
if(now==a3&&!c){
a[x].d=paidui[s];
s++;
c=true;
}
if(max==-999999){
if(a1=="PASS"||a2=="PASS"||a3=="PASS"){
bool c=false;
if(a1=="PASS"){
a[x].b=paidui[s];
s++;
c=true;
}
if(a2=="PASS"&&!c){
a[x].c=paidui[s];
s++;
c=true;
}
if(a3=="PASS"&&!c){
a[x].d=paidui[s];
s++;
c=true;
}
cout<<a[x].a<<" used "<<"PASS,now p="<<floor(p)<<"."<<endl;
x+=fx;
continue;
}else if(a1=="TURN"||a2=="TURN"||a3=="TURN"){
bool c=false;
if(a1=="TURN"){
a[x].b=paidui[s];
s++;
c=true;
}
if(a2=="TURN"&&!c){
a[x].c=paidui[s];
s++;
c=true;
}
if(a3=="TURN"&&!c){
a[x].d=paidui[s];
s++;
c=true;
}
cout<<a[x].a<<" used TURN,now p="<<p<<"."<<endl;
fx=-fx;
x+=fx;
continue;
}else if(a1=="DOUBLE"||a2=="DOUBLE"||a3=="DOUBLE"){
bool c=false;
if(a1=="DOUBLE"){
a[x].b=paidui[s];
s++;
c=true;
}
if(a2=="DOUBLE"&&!c){
c=true;
a[x].c=paidui[s];
s++;
}
if(a3=="DOUBLE"&&!c){
c=true;
a[x].d=paidui[s];
s++;
}
cout<<a[x].a<<" used DOUBLE,now p="<<p<<"."<<endl;
flag=true;
x+=fx;
continue;
}
}
p=max;
if(p==-999999){
faild=x;
cout<<a[x].a<<" lost the game."<<endl;
break;
}
if(p>99){
faild=x;
cout<<a[x].a<<" lost the game."<<endl;
break;
}else{
cout<<a[x].a<<" used "<<now<<",now p="<<p<<"."<<endl;
}
}
x+=fx;
}
}
return 0;
}