#include<iostream>
#include<stdio.h>
#include<stdint.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<string>
#include<assert.h>
#include<math.h>
#include<chrono>
#include<random>
#include<bitset>
using namespace std;
const int64_t INF = (int64_t) 1e9 + 5;
const int64_t mINF = (int64_t) 2 * 1e6 + 5;
const int64_t MOD = (int64_t) 1e9 + 19972207;
const int nbit = 30;
const int ndig = 10;
const int nchar = 26;
const int p1 = 31;
const int p2 = 53;
const int D = 4;
int dr[D] = {0, 1, 0, -1};
int dc[D] = {1, 0, -1, 0};
// 0 right // 1 down // 2 left // 3 up
struct Solution
{
int n;
int t;
int q;
int cur;
int seed;
int mul;
int add;
int LOG;
int time;
vector<int> f;
vector<int> tin;
vector<int> tout;
vector<int> pos;
vector<int> depth;
vector<vector<int> > adj;
vector<vector<int> > rmq;
vector<pair<int, int> > e;
Solution() {}
void solve()
{
cin >> n;
t = 0;
LOG = 0;
time = 0;
adj.resize(n);
tin.resize(n);
tout.resize(n);
f.resize(n, -1);
depth.resize(n, 0);
for(int i = 0; i < n - 1; i++)
{
int u;
int v;
cin >> u >> v;
u--; v--;
adj[u].push_back(v);
adj[v].push_back(u);
e.emplace_back(u, v);
}
DFS();
while(MASK(LOG) <= t) LOG++;
rmq.resize(LOG, vector<int>(t, 0));
for(int i = 0; i < (int) e.size(); i++)
{
if(depth[e[i].first] < depth[e[i].second]) swap(e[i].first, e[i].second);
}
for(int i = 0; i < t; i++)
{
rmq[0][i] = pos[i];
}
for(int i = 1; i < LOG; i++)
{
for(int j = 0; j + MASK(i) - 1 < t; j++)
{
int d1 = depth[ rmq[i - 1][j] ];
int d2 = depth[ rmq[i - 1][j + MASK(i - 1)] ];
if(d1 < d2) rmq[i][j] = rmq[i - 1][j];
else rmq[i][j] = rmq[i - 1][j + MASK(i - 1) ];
}
}
cin >> q >> seed >> mul >> add;
cur = seed;
int64_t ans = 0;
for(int i = 0; i < q; i++)
{
int e1 = getRandom(n - 1);
int u1 = getRandom(n); int v1 = getRandom(n);
int e2 = getRandom(n - 1);
int u2 = getRandom(n); int v2 = getRandom(n);
int64_t tmp = e1 == e2 || u1 == v1 || u2 == v2 ? MOD - 1 : query(e1, u1, v1, e2, u2, v2);
ans = (227LL * ans + tmp) % MOD;
}
cout << ans << "\n";
// cin >> q;
// for(int i = 0; i < q; i++)
// {
// int e1; int u1; int v1; int e2; int u2; int v2;
// cin >> e1 >> u1 >> v1 >> e2 >> u2 >> v2;
// if(e1 == e2 || u1 == v1 || u2 == v2) cout << "MOD\n";
// else cout << query(e1, u1, v1, e2, u2, v2) << "\n";
// }
}
int query(int x, int a, int b, int y, int c, int d)
{
x--; y--; a--; b--; c--; d--;
int u1 = e[x].first; int u2 = e[y].first;
int pa = 0; int pb = 0; int pc = 0; int pd = 0;
updateP(pa, a, u1, u2); updateP(pb, b, u1, u2);
updateP(pc, c, u1, u2); updateP(pd, d, u1, u2);
if(pa > pb)
{
swap(a, b);
swap(pa, pb);
}
if(pc > pd)
{
swap(c, d);
swap(pc, pd);
}
if(pa != pb)
{
if(pc == pd) return 1;
return (pa == pc && pb == pd);
}
if(pa != pc) return (pa == pb) + (pc == pd);
// pa == pb && pa == pc
if(pc != pd) return 1;
// pa == pb && pa == pc && pc == pd
if(checkPaths(a, b, c, d)) return 3;
return 2;
}
bool checkPaths(int a, int b, int c, int d)
{
int ab = LCA(a, b);
int cd = LCA(c, d);
if(Intersect(ab, a, cd, c)) return true;
if(Intersect(ab, a, cd, d)) return true;
if(Intersect(ab, b, cd, c)) return true;
if(Intersect(ab, b, cd, d)) return true;
return false;
}
bool Intersect(int x, int y, int u, int v)
{
if(u == v || x == y) return false; // one of the path only 1 node
if(!check(x, u) && !check(u, x)) return false; // 2 different subtree
if(check(x, u)) // x is always in the subtree of u
{
swap(x, u);
swap(y, v);
}
return (check(x, v) && x != v && LCA(y, v) != x);
}
void updateP(int& a, int& u, int& x, int& y)
{
if(check(x, u) && check(a, x)) a = x;
if(check(y, u) && check(a, y)) a = y;
}
bool check(int& u, int& v)
{
return tin[u] <= tin[v] && tin[v] <= tout[u];
}
int LCA(int i, int j)
{
i = f[i]; j = f[j];
if(i > j) swap(i, j);
int len = j - i + 1;
int k = 31 - __builtin_clz(len);
if(depth[ rmq[k][i] ] < depth[ rmq[k][j - MASK(k) + 1] ]) return rmq[k][i];
return rmq[k][j - MASK(k) + 1];
}
void DFS(int u = 0)
{
f[u] = t++;
tin[u] = time++;
pos.push_back(u);
for(int i = 0; i < (int) adj[u].size(); i++)
{
int v = adj[u][i];
if(f[v] != -1) continue;
depth[v] = depth[u] + 1;
DFS(v);
pos.push_back(u);
t++;
}
tout[u] = time++;
}
int getRandom(int x)
{
cur = (1LL * mul * cur + add) % MOD;
return 1 + cur % x;
}
int modsub(int t1, int t2)
{
int64_t res = t1 - t2;
if(res < 0) res += MOD;
return res;
}
int modadd(int t1, int t2)
{
int64_t res = t1 + t2;
if(res >= MOD) res -= MOD;
return res;
}
int modmul(int t1, int t2)
{
int64_t res = 1LL * t1 * t2;
return (res % MOD);
}
bool BIT(int mask, int j)
{
return (mask & MASK(j));
}
int MASK(int j)
{
return (1 << j);
}
int64_t Abs(int64_t t1)
{
if(t1 < 0) return -t1;
return t1;
}
};
void __startup()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
freopen("CHUTRINH.INP", "r", stdin);
freopen("CHUTRINH.OUT", "w", stdout);
}
int main()
{
__startup();
int t = 1;
int sub = 0;
cin >> sub;
// cin >> t;
for(int i = 1; i <= t; i++)
{
Solution().solve();
}
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHN0ZGlvLmg+CiNpbmNsdWRlPHN0ZGludC5oPgojaW5jbHVkZTx2ZWN0b3I+CiNpbmNsdWRlPGFsZ29yaXRobT4KI2luY2x1ZGU8dXRpbGl0eT4KI2luY2x1ZGU8c2V0PgojaW5jbHVkZTxtYXA+CiNpbmNsdWRlPHF1ZXVlPgojaW5jbHVkZTxzdGFjaz4KI2luY2x1ZGU8ZGVxdWU+CiNpbmNsdWRlPHN0cmluZz4KI2luY2x1ZGU8YXNzZXJ0Lmg+CiNpbmNsdWRlPG1hdGguaD4KI2luY2x1ZGU8Y2hyb25vPgojaW5jbHVkZTxyYW5kb20+CiNpbmNsdWRlPGJpdHNldD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQ2NF90IElORiA9IChpbnQ2NF90KSAxZTkgKyA1Owpjb25zdCBpbnQ2NF90IG1JTkYgPSAoaW50NjRfdCkgMiAqIDFlNiArIDU7CmNvbnN0IGludDY0X3QgTU9EID0gKGludDY0X3QpIDFlOSArIDE5OTcyMjA3Owpjb25zdCBpbnQgbmJpdCA9IDMwOwpjb25zdCBpbnQgbmRpZyA9IDEwOwpjb25zdCBpbnQgbmNoYXIgPSAyNjsKY29uc3QgaW50IHAxID0gMzE7CmNvbnN0IGludCBwMiA9IDUzOwpjb25zdCBpbnQgRCA9IDQ7CmludCBkcltEXSA9IHswLCAxLCAwLCAtMX07CmludCBkY1tEXSA9IHsxLCAwLCAtMSwgMH07Ci8vIDAgcmlnaHQgLy8gMSBkb3duIC8vIDIgbGVmdCAvLyAzIHVwCgpzdHJ1Y3QgU29sdXRpb24KewogICAgaW50IG47CiAgICBpbnQgdDsKICAgIGludCBxOwogICAgaW50IGN1cjsKICAgIGludCBzZWVkOwogICAgaW50IG11bDsKICAgIGludCBhZGQ7CiAgICBpbnQgTE9HOwogICAgaW50IHRpbWU7CiAgICB2ZWN0b3I8aW50PiBmOwogICAgdmVjdG9yPGludD4gdGluOwogICAgdmVjdG9yPGludD4gdG91dDsKICAgIHZlY3RvcjxpbnQ+IHBvczsKICAgIHZlY3RvcjxpbnQ+IGRlcHRoOwogICAgdmVjdG9yPHZlY3RvcjxpbnQ+ID4gYWRqOwogICAgdmVjdG9yPHZlY3RvcjxpbnQ+ID4gcm1xOwogICAgdmVjdG9yPHBhaXI8aW50LCBpbnQ+ID4gZTsKICAgIFNvbHV0aW9uKCkge30KCiAgICB2b2lkIHNvbHZlKCkKICAgIHsKICAgICAgICBjaW4gPj4gbjsKICAgICAgICB0ID0gMDsKICAgICAgICBMT0cgPSAwOwogICAgICAgIHRpbWUgPSAwOwogICAgICAgIGFkai5yZXNpemUobik7CiAgICAgICAgdGluLnJlc2l6ZShuKTsKICAgICAgICB0b3V0LnJlc2l6ZShuKTsKICAgICAgICBmLnJlc2l6ZShuLCAtMSk7CiAgICAgICAgZGVwdGgucmVzaXplKG4sIDApOwogICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuIC0gMTsgaSsrKQogICAgICAgIHsKICAgICAgICAgICAgaW50IHU7CiAgICAgICAgICAgIGludCB2OwogICAgICAgICAgICBjaW4gPj4gdSA+PiB2OwogICAgICAgICAgICB1LS07IHYtLTsKCiAgICAgICAgICAgIGFkalt1XS5wdXNoX2JhY2sodik7CiAgICAgICAgICAgIGFkalt2XS5wdXNoX2JhY2sodSk7CiAgICAgICAgICAgIGUuZW1wbGFjZV9iYWNrKHUsIHYpOwogICAgICAgIH0KCiAgICAgICAgREZTKCk7CiAgICAgICAgd2hpbGUoTUFTSyhMT0cpIDw9IHQpIExPRysrOwogICAgICAgIHJtcS5yZXNpemUoTE9HLCB2ZWN0b3I8aW50Pih0LCAwKSk7CiAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IChpbnQpIGUuc2l6ZSgpOyBpKyspCiAgICAgICAgewogICAgICAgICAgICBpZihkZXB0aFtlW2ldLmZpcnN0XSA8IGRlcHRoW2VbaV0uc2Vjb25kXSkgc3dhcChlW2ldLmZpcnN0LCBlW2ldLnNlY29uZCk7CiAgICAgICAgfQoKICAgICAgICBmb3IoaW50IGkgPSAwOyBpIDwgdDsgaSsrKQogICAgICAgIHsKICAgICAgICAgICAgcm1xWzBdW2ldID0gcG9zW2ldOwogICAgICAgIH0KCiAgICAgICAgZm9yKGludCBpID0gMTsgaSA8IExPRzsgaSsrKQogICAgICAgIHsKICAgICAgICAgICAgZm9yKGludCBqID0gMDsgaiArIE1BU0soaSkgLSAxIDwgdDsgaisrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpbnQgZDEgPSBkZXB0aFsgcm1xW2kgLSAxXVtqXSBdOwogICAgICAgICAgICAgICAgaW50IGQyID0gZGVwdGhbIHJtcVtpIC0gMV1baiArIE1BU0soaSAtIDEpXSBdOwoKICAgICAgICAgICAgICAgIGlmKGQxIDwgZDIpIHJtcVtpXVtqXSA9IHJtcVtpIC0gMV1bal07CiAgICAgICAgICAgICAgICBlbHNlIHJtcVtpXVtqXSA9IHJtcVtpIC0gMV1baiArIE1BU0soaSAtIDEpIF07CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIGNpbiA+PiBxID4+IHNlZWQgPj4gbXVsID4+IGFkZDsKICAgICAgICBjdXIgPSBzZWVkOwogICAgICAgIGludDY0X3QgYW5zID0gMDsKICAgICAgICBmb3IoaW50IGkgPSAwOyBpIDwgcTsgaSsrKQogICAgICAgIHsKICAgICAgICAgICAgaW50IGUxID0gZ2V0UmFuZG9tKG4gLSAxKTsKICAgICAgICAgICAgaW50IHUxID0gZ2V0UmFuZG9tKG4pOyBpbnQgdjEgPSBnZXRSYW5kb20obik7CiAgICAgICAgICAgIGludCBlMiA9IGdldFJhbmRvbShuIC0gMSk7CiAgICAgICAgICAgIGludCB1MiA9IGdldFJhbmRvbShuKTsgaW50IHYyID0gZ2V0UmFuZG9tKG4pOwogICAgICAgICAgICBpbnQ2NF90IHRtcCA9IGUxID09IGUyIHx8IHUxID09IHYxIHx8IHUyID09IHYyID8gTU9EIC0gMSA6IHF1ZXJ5KGUxLCB1MSwgdjEsIGUyLCB1MiwgdjIpOwoKICAgICAgICAgICAgYW5zID0gKDIyN0xMICogYW5zICsgdG1wKSAlIE1PRDsKICAgICAgICB9CiAgICAgICAgY291dCA8PCBhbnMgPDwgIlxuIjsKLy8gICAgICAgIGNpbiA+PiBxOwovLyAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IHE7IGkrKykKLy8gICAgICAgIHsKLy8gICAgICAgICAgICBpbnQgZTE7IGludCB1MTsgaW50IHYxOyBpbnQgZTI7IGludCB1MjsgaW50IHYyOwovLyAgICAgICAgICAgIGNpbiA+PiBlMSA+PiB1MSA+PiB2MSA+PiBlMiA+PiB1MiA+PiB2MjsKLy8gICAgICAgICAgICBpZihlMSA9PSBlMiB8fCB1MSA9PSB2MSB8fCB1MiA9PSB2MikgY291dCA8PCAiTU9EXG4iOwovLyAgICAgICAgICAgIGVsc2UgY291dCA8PCBxdWVyeShlMSwgdTEsIHYxLCBlMiwgdTIsIHYyKSA8PCAiXG4iOwovLyAgICAgICAgfQogICAgfQoKICAgIGludCBxdWVyeShpbnQgeCwgaW50IGEsIGludCBiLCBpbnQgeSwgaW50IGMsIGludCBkKQogICAgewogICAgICAgIHgtLTsgeS0tOyBhLS07IGItLTsgYy0tOyBkLS07CiAgICAgICAgaW50IHUxID0gZVt4XS5maXJzdDsgaW50IHUyID0gZVt5XS5maXJzdDsKICAgICAgICBpbnQgcGEgPSAwOyBpbnQgcGIgPSAwOyBpbnQgcGMgPSAwOyBpbnQgcGQgPSAwOwogICAgICAgIHVwZGF0ZVAocGEsIGEsIHUxLCB1Mik7IHVwZGF0ZVAocGIsIGIsIHUxLCB1Mik7CiAgICAgICAgdXBkYXRlUChwYywgYywgdTEsIHUyKTsgdXBkYXRlUChwZCwgZCwgdTEsIHUyKTsKCiAgICAgICAgaWYocGEgPiBwYikKICAgICAgICB7CiAgICAgICAgICAgIHN3YXAoYSwgYik7CiAgICAgICAgICAgIHN3YXAocGEsIHBiKTsKICAgICAgICB9CiAgICAgICAgaWYocGMgPiBwZCkKICAgICAgICB7CiAgICAgICAgICAgIHN3YXAoYywgZCk7CiAgICAgICAgICAgIHN3YXAocGMsIHBkKTsKICAgICAgICB9CiAgICAgICAgaWYocGEgIT0gcGIpCiAgICAgICAgewogICAgICAgICAgICBpZihwYyA9PSBwZCkgcmV0dXJuIDE7CiAgICAgICAgICAgIHJldHVybiAocGEgPT0gcGMgJiYgcGIgPT0gcGQpOwogICAgICAgIH0KCiAgICAgICAgaWYocGEgIT0gcGMpIHJldHVybiAocGEgPT0gcGIpICsgKHBjID09IHBkKTsKICAgICAgICAvLyBwYSA9PSBwYiAmJiBwYSA9PSBwYwogICAgICAgIGlmKHBjICE9IHBkKSByZXR1cm4gMTsKICAgICAgICAvLyBwYSA9PSBwYiAmJiBwYSA9PSBwYyAmJiBwYyA9PSBwZAogICAgICAgIGlmKGNoZWNrUGF0aHMoYSwgYiwgYywgZCkpIHJldHVybiAzOwogICAgICAgIHJldHVybiAyOwogICAgfQoKICAgIGJvb2wgY2hlY2tQYXRocyhpbnQgYSwgaW50IGIsIGludCBjLCBpbnQgZCkKICAgIHsKICAgICAgICBpbnQgYWIgPSBMQ0EoYSwgYik7CiAgICAgICAgaW50IGNkID0gTENBKGMsIGQpOwogICAgICAgIGlmKEludGVyc2VjdChhYiwgYSwgY2QsIGMpKSByZXR1cm4gdHJ1ZTsKICAgICAgICBpZihJbnRlcnNlY3QoYWIsIGEsIGNkLCBkKSkgcmV0dXJuIHRydWU7CiAgICAgICAgaWYoSW50ZXJzZWN0KGFiLCBiLCBjZCwgYykpIHJldHVybiB0cnVlOwogICAgICAgIGlmKEludGVyc2VjdChhYiwgYiwgY2QsIGQpKSByZXR1cm4gdHJ1ZTsKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICB9CgogICAgYm9vbCBJbnRlcnNlY3QoaW50IHgsIGludCB5LCBpbnQgdSwgaW50IHYpCiAgICB7CiAgICAgICAgaWYodSA9PSB2IHx8IHggPT0geSkgcmV0dXJuIGZhbHNlOyAvLyBvbmUgb2YgdGhlIHBhdGggb25seSAxIG5vZGUKICAgICAgICBpZighY2hlY2soeCwgdSkgJiYgIWNoZWNrKHUsIHgpKSByZXR1cm4gZmFsc2U7IC8vIDIgZGlmZmVyZW50IHN1YnRyZWUKCiAgICAgICAgaWYoY2hlY2soeCwgdSkpIC8vIHggaXMgYWx3YXlzIGluIHRoZSBzdWJ0cmVlIG9mIHUKICAgICAgICB7CiAgICAgICAgICAgIHN3YXAoeCwgdSk7CiAgICAgICAgICAgIHN3YXAoeSwgdik7CiAgICAgICAgfQogICAgICAgIHJldHVybiAoY2hlY2soeCwgdikgJiYgeCAhPSB2ICYmIExDQSh5LCB2KSAhPSB4KTsKICAgIH0KCiAgICB2b2lkIHVwZGF0ZVAoaW50JiBhLCBpbnQmIHUsIGludCYgeCwgaW50JiB5KQogICAgewogICAgICAgIGlmKGNoZWNrKHgsIHUpICYmIGNoZWNrKGEsIHgpKSBhID0geDsKICAgICAgICBpZihjaGVjayh5LCB1KSAmJiBjaGVjayhhLCB5KSkgYSA9IHk7CiAgICB9CgogICAgYm9vbCBjaGVjayhpbnQmIHUsIGludCYgdikKICAgIHsKICAgICAgICByZXR1cm4gdGluW3VdIDw9IHRpblt2XSAmJiB0aW5bdl0gPD0gdG91dFt1XTsKICAgIH0KCiAgICBpbnQgTENBKGludCBpLCBpbnQgaikKICAgIHsKICAgICAgICBpID0gZltpXTsgaiA9IGZbal07CiAgICAgICAgaWYoaSA+IGopIHN3YXAoaSwgaik7CgogICAgICAgIGludCBsZW4gPSBqIC0gaSArIDE7CiAgICAgICAgaW50IGsgPSAzMSAtIF9fYnVpbHRpbl9jbHoobGVuKTsKICAgICAgICBpZihkZXB0aFsgcm1xW2tdW2ldIF0gPCBkZXB0aFsgcm1xW2tdW2ogLSBNQVNLKGspICsgMV0gXSkgcmV0dXJuIHJtcVtrXVtpXTsKICAgICAgICByZXR1cm4gcm1xW2tdW2ogLSBNQVNLKGspICsgMV07CiAgICB9CgogICAgdm9pZCBERlMoaW50IHUgPSAwKQogICAgewogICAgICAgIGZbdV0gPSB0Kys7CiAgICAgICAgdGluW3VdID0gdGltZSsrOwogICAgICAgIHBvcy5wdXNoX2JhY2sodSk7CgogICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCAoaW50KSBhZGpbdV0uc2l6ZSgpOyBpKyspCiAgICAgICAgewogICAgICAgICAgICBpbnQgdiA9IGFkalt1XVtpXTsKICAgICAgICAgICAgaWYoZlt2XSAhPSAtMSkgY29udGludWU7CgogICAgICAgICAgICBkZXB0aFt2XSA9IGRlcHRoW3VdICsgMTsKICAgICAgICAgICAgREZTKHYpOwoKICAgICAgICAgICAgcG9zLnB1c2hfYmFjayh1KTsKICAgICAgICAgICAgdCsrOwogICAgICAgIH0KICAgICAgICB0b3V0W3VdID0gdGltZSsrOwogICAgfQoKICAgIGludCBnZXRSYW5kb20oaW50IHgpCiAgICB7CiAgICAgICAgY3VyID0gKDFMTCAqIG11bCAqIGN1ciArIGFkZCkgJSBNT0Q7CiAgICAgICAgcmV0dXJuIDEgKyBjdXIgJSB4OwogICAgfQoKICAgIGludCBtb2RzdWIoaW50IHQxLCBpbnQgdDIpCiAgICB7CiAgICAgICAgaW50NjRfdCByZXMgPSB0MSAtIHQyOwogICAgICAgIGlmKHJlcyA8IDApIHJlcyArPSBNT0Q7CgogICAgICAgIHJldHVybiByZXM7CiAgICB9CgogICAgaW50IG1vZGFkZChpbnQgdDEsIGludCB0MikKICAgIHsKICAgICAgICBpbnQ2NF90IHJlcyA9IHQxICsgdDI7CiAgICAgICAgaWYocmVzID49IE1PRCkgcmVzIC09IE1PRDsKCiAgICAgICAgcmV0dXJuIHJlczsKICAgIH0KCiAgICBpbnQgbW9kbXVsKGludCB0MSwgaW50IHQyKQogICAgewogICAgICAgIGludDY0X3QgcmVzID0gMUxMICogdDEgKiB0MjsKICAgICAgICByZXR1cm4gKHJlcyAlIE1PRCk7CiAgICB9CgogICAgYm9vbCBCSVQoaW50IG1hc2ssIGludCBqKQogICAgewogICAgICAgIHJldHVybiAobWFzayAmIE1BU0soaikpOwogICAgfQoKICAgIGludCBNQVNLKGludCBqKQogICAgewogICAgICAgIHJldHVybiAoMSA8PCBqKTsKICAgIH0KCiAgICBpbnQ2NF90IEFicyhpbnQ2NF90IHQxKQogICAgewogICAgICAgIGlmKHQxIDwgMCkgcmV0dXJuIC10MTsKICAgICAgICByZXR1cm4gdDE7CiAgICB9Cn07Cgp2b2lkIF9fc3RhcnR1cCgpCnsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwogICAgY2luLnRpZShOVUxMKTsKCiAgICBmcmVvcGVuKCJDSFVUUklOSC5JTlAiLCAiciIsIHN0ZGluKTsKICAgIGZyZW9wZW4oIkNIVVRSSU5ILk9VVCIsICJ3Iiwgc3Rkb3V0KTsKfQoKaW50IG1haW4oKQp7CiAgICBfX3N0YXJ0dXAoKTsKICAgIGludCB0ID0gMTsKICAgIGludCBzdWIgPSAwOwogICAgY2luID4+IHN1YjsKLy8gICAgY2luID4+IHQ7CgogICAgZm9yKGludCBpID0gMTsgaSA8PSB0OyBpKyspCiAgICB7CiAgICAgICAgU29sdXRpb24oKS5zb2x2ZSgpOwogICAgfQoKICAgIHJldHVybiAwOwp9Cg==