#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define make(type, x) type x; cin>>x;
#define make2(type, x, y) type x, y; cin>>x>>y;
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
#define make4(type, x, y, z, t) type x, y, z, t; cin>>x>>y>>z>>t;
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;
template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
const int N = 12;
const int R = 112;
int dice[N][N];
LD dp[1 << N];
int fir[1 << N];
int order[N];
bool accept_sub[1 << N][N][N];
bool accept[N][R];
LD cdf[R];
int valid[R];
const LD kEps = 1e-9;
void RecomputeDp(int n) {
dp[0] = -1;
for (int mask = 2; mask < (2 << n); mask += 2) {
int pop = __builtin_popcount(mask);
dp[mask] = -1;
RE (bit, n) {
if (mask & (1 << bit)) {
int prev = mask - (1 << bit);
LD res = 0;
REP (side, 6) {
if (dp[prev] > cdf[dice[bit][side] + pop]) {
accept_sub[mask][bit][side] = 0;
} else {
accept_sub[mask][bit][side] = 1;
}
res += max(dp[prev], cdf[dice[bit][side] + pop]);
}
res /= 6;
debug(bit, res);
if (res > dp[mask]) {
fir[mask] = bit;
dp[mask] = res;
}
}
}
debug(mask, dp[mask]);
}
int full_mask = (2 << n) - 2;
int cnt = 0;
while (full_mask) {
cnt++;
int ziom = fir[full_mask];
debug(cnt, ziom);
order[cnt] = ziom;
REP (side, 6) {
accept[ziom][dice[ziom][side]] = accept_sub[full_mask][ziom][side];
}
full_mask -= (1 << ziom);
}
}
LD wins[R];
LD mult[R];
void RecomputeCdf(int turns) {
cdf[R - 1] = 1;
VPII mults;
REP (i, R) {
mults.PB({mult[i], i});
}
sort(ALL(mults), greater<PII>());
int DUPA = 16;
while (SZ(mults) > DUPA || mults.back().st < mults[0].st / 4) { mults.pop_back(); }
vector<LD> vals;
VI wazni_panowie;
int gowno = 0;
for (auto p : mults) {
wazni_panowie.PB(p.nd);
if (p.st == 0) {
vals.PB(54654);
} else {
vals.PB(wins[p.nd] / p.st + gowno / 1e6);
}
gowno++;
}
vals.PB(0);
wazni_panowie.PB(0);
vals.PB(1);
wazni_panowie.PB(R - 1);
sort(ALL(wazni_panowie));
sort(ALL(vals));
debug(vals);
debug(wazni_panowie);
for (int i = 0; i < SZ(wazni_panowie) - 1; i++) {
FOR (j, wazni_panowie[i], wazni_panowie[i + 1] - 1) {
cdf[j] = ((j - wazni_panowie[i]) * vals[i + 1] + (wazni_panowie[i + 1] - j) * vals[i]) / (wazni_panowie[i + 1] - wazni_panowie[i]);
}
}
REP (i, R) {
debug(cdf[i]);
}
}
const int kIter = 10000;
#ifdef LOCAL
const int kPeriod = 1;
#else
const int kPeriod = 12;
#endif
#undef int
int main() {
#define int long long
int n;
cin>>n;
RE (i, n) {
REP (side, 6) {
cin>>dice[i][side];
}
}
int won = 0;
mult[0] = 1;
wins[R - 1] = 1;
mult[R - 1] = 1;
REP (iter, kIter) {
if (iter % kPeriod == 0) {
if (iter) { RecomputeCdf(iter); }
RecomputeDp(n);
}
int sc = 0;
RE (i, n) {
cout<<order[i]<<endl;
int res;
cin>>res;
res += i - 1;
if (accept[order[i]][res]) {
cout<<"Yes"<<endl;
sc = res + n - i + 1;
break;
} else {
cout<<"No"<<endl;
}
}
string hehs;
cin>>hehs;
if (hehs == "Win") {
wins[sc]++;
won++;
}
mult[sc]++;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgTVAgbWFrZV9wYWlyCiNkZWZpbmUgUEIgcHVzaF9iYWNrCiNkZWZpbmUgaW50IGxvbmcgbG9uZwojZGVmaW5lIHN0IGZpcnN0CiNkZWZpbmUgbmQgc2Vjb25kCiNkZWZpbmUgcmQgdGhpcmQKI2RlZmluZSBGT1IoaSwgYSwgYikgZm9yKGludCBpID0oYS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V0PDx2PDwiLCAiOyByZXR1cm4gb3V0PDwiKSI7IH0KCmNvbnN0IGludCBOID0gMTI7CmNvbnN0IGludCBSID0gMTEyOwppbnQgZGljZVtOXVtOXTsKTEQgZHBbMSA8PCBOXTsKaW50IGZpclsxIDw8IE5dOwppbnQgb3JkZXJbTl07CmJvb2wgYWNjZXB0X3N1YlsxIDw8IE5dW05dW05dOwpib29sIGFjY2VwdFtOXVtSXTsKTEQgY2RmW1JdOwppbnQgdmFsaWRbUl07CmNvbnN0IExEIGtFcHMgPSAxZS05Owp2b2lkIFJlY29tcHV0ZURwKGludCBuKSB7CiAgZHBbMF0gPSAtMTsKICBmb3IgKGludCBtYXNrID0gMjsgbWFzayA8ICgyIDw8IG4pOyBtYXNrICs9IDIpIHsKICAgIGludCBwb3AgPSBfX2J1aWx0aW5fcG9wY291bnQobWFzayk7CiAgICBkcFttYXNrXSA9IC0xOwogICAgUkUgKGJpdCwgbikgewogICAgICBpZiAobWFzayAmICgxIDw8IGJpdCkpIHsKICAgICAgICBpbnQgcHJldiA9IG1hc2sgLSAoMSA8PCBiaXQpOwogICAgICAgIExEIHJlcyA9IDA7CiAgICAgICAgUkVQIChzaWRlLCA2KSB7CiAgICAgICAgICBpZiAoZHBbcHJldl0gPiBjZGZbZGljZVtiaXRdW3NpZGVdICsgcG9wXSkgewogICAgICAgICAgICBhY2NlcHRfc3ViW21hc2tdW2JpdF1bc2lkZV0gPSAwOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgYWNjZXB0X3N1YlttYXNrXVtiaXRdW3NpZGVdID0gMTsKICAgICAgICAgIH0KICAgICAgICAgIHJlcyArPSBtYXgoZHBbcHJldl0sIGNkZltkaWNlW2JpdF1bc2lkZV0gKyBwb3BdKTsKICAgICAgICB9CiAgICAgICAgcmVzIC89IDY7CiAgICAgICAgZGVidWcoYml0LCByZXMpOwogICAgICAgIGlmIChyZXMgPiBkcFttYXNrXSkgewogICAgICAgICAgZmlyW21hc2tdID0gYml0Ow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