#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include <bits/stdc++.h>
#define ld double
#define ll int
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define eb emplace_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}
#define si(a) (ll)(a.size())
using namespace std;
#define maxn 1005
map<ll,char> mp;
string kod[maxn];
ll sad = 0;
bool test = 0;
ll F(ll x,ll y){
string a = kod[x];
string b = kod[y];
ll ans = 0;
for(ll i = 0;i<8;i++) ans+=(a[i]==b[i]);
return ans;
}
void reshi(vector<ll> v){
//dbg(si(v));
if(si(v)==1){
return;
}
ll xopt = -1,maxi = llinf;
for(ll x : v){
vector<vector<ll> > cur(9);
for(ll y : v){
cur[g[x][y]].pb(y);
}
ll curmax = 0;
for(vector<ll> s : cur) curmax = max(curmax,si(s));
if(curmax<maxi){
xopt = x;
}
}
cout<<kod[xopt]<<endl;
ll cnt = 0;
if(!test) cin >> cnt;
else cnt = F(sad,xopt);
vector<vector<ll> > cur(9);
for(ll y : v){
cur[F(xopt,y)].pb(y);
}
reshi(cur[cnt]);
}
void tc(){
vector<ll> v;
for(ll i = 0;i<960;i++) v.pb(i);
reshi(v);
}
map<string,bool> was;
int main(){
int t; t = 1;
mp[0] = mp[1] = 'B';
mp[2] = mp[3] = 'N';
mp[4] = mp[5] = 'R';
mp[6] = 'Q';
mp[7] = 'K';
vector<vector<ll> > v;
v.pb({});
for(ll i = 0;i<960;i++) v[0].pb(i);
ll tsz = 0;
vector<ll> p(8);
iota(all(p),0);
do{
ll b1 = -1,b2 = -1;
ll r1 = -1,r2 = -1;
ll k = -1;
string cur = "";
for(ll i = 0;i<8;i++){
if(mp[p[i]]=='B'){
if(b1==-1) b1 = i;
else b2 = i;
}else if(mp[p[i]]=='R'){
if(r1==-1) r1 = i;
else r2 = i;
}else if(mp[p[i]]=='K'){
k = i;
}
cur+=mp[p[i]];
}
if(was[cur]) continue;
was[cur] = 1;
bool ok = 1;
ok&=((k>=r1)&&(k<=r2));
ok&=((b1&1)!=(b2&1));
if(ok) kod[tsz++] = cur;
}while(next_permutation(all(p)));
for(ll i = 0;i<960;i++) for(ll j = 0;j<960;j++) g[i][j] = F(i,j);
while(1){
//here;
string s; cin >> s;
if(s=="END") return 0;
cin >> t;
if(test){
string curs;
cin >> curs;
for(ll i = 0;i<960;i++) if(kod[i]==curs) sad = i;
}
tc();
}
return (0-0);
}