// #include "atcoder/convolution" #include "atcoder/dsu" #include "atcoder/fenwicktree" #include "atcoder/lazysegtree" #include "atcoder/math" #include "atcoder/maxflow" #include "atcoder/mincostflow" #include "atcoder/modint" #include "atcoder/scc" #include "atcoder/segtree" #include "atcoder/string" #include "atcoder/twosat" using namespace atcoder; #include using namespace std; // #include #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i,a,b) for (int i = (int)(a); i < (int)(b); i++) #define all(v) v.begin(),v.end() #define inc(x,l,r) ((l)<=(x)&&(x)<(r)) #define Unique(x) sort(all(x)), x.erase(unique(all(x)), x.end()) #define pcnt __builtin_popcountll typedef long long ll; #define int ll using ld = long double; using vi = vector; using vs = vector; using P = pair; using vp = vector

; // using Bint = boost::multiprecision::cpp_int; template bool chmax(T1 &a, const T2 b) {if (a < b) {a = b; return true;} else return false; } template bool chmin(T1 &a, const T2 b) {if (a > b) {a = b; return true;} else return false; } template using priority_queue_greater = priority_queue, greater>; template istream &operator>>(istream& is,vector &v){for(T &in:v)is>>in;return is;} template ostream &operator<< (ostream &os, const pair &p){os << p.first <<" "<> (istream &is, modint1000000007 &m){ll in;is>>in;m=in;return is;} ostream &operator<< (ostream &os, const modint998244353 &m){os << m.val();return os;} istream &operator>> (istream &is, modint998244353 &m){ll in;is>>in;m=in;return is;} template void input(T&... a){(cin>> ... >> a);} #ifdef LOCAL template ostream &operator<<(ostream &os,const vector &v){os<<"\x1b[32m";rep(i,v.size())os< void print(T& a){cout << "\x1b[32m"<< a<< '\n' << "\x1b[0m";} template void print(const T&a, const Ts&... b){cout << "\x1b[32m" << a;(cout<<...<<(cout<<' ',b));cout<<'\n' << "\x1b[0m";} #else template ostream &operator<<(ostream &os,const vector &v){rep(i,v.size())os< void print(T& a){cout << a<< '\n';} template void print(const T&a, const Ts&... b){cout << a;(cout<<...<<(cout<<' ',b));cout<<'\n';} #endif #define VI(v,n) vi v(n); input(v) #define INT(...) int __VA_ARGS__; input(__VA_ARGS__) #define STR(...) string __VA_ARGS__; input(__VA_ARGS__) #define CHAR(...) char __VA_ARGS__; input(__VA_ARGS__) int sign(ll x){return x>0?1:x<0?-1:0;} ll ceil(ll x,ll y){assert(y!=0);if(sign(x)==sign(y))return (x+y-1)/y;return -((-x/y));} ll floor(ll x,ll y){assert(y!=0);if(sign(x)==sign(y))return x/y;if(y<0)x*=-1,y*=-1;return x/y-(x%y<0);} ll abs(ll x,ll y){return abs(x-y);} ll bit(int n){return 1ll< class dynamic_segtree { public: dynamic_segtree(ll n) : n(n), root(nullptr) {} void set(ll p, S x) { assert(p < n); set(root, 0, n, p, x); } S get(ll p) const { assert(p < n); return get(root, 0, n, p); } S prod(ll l, ll r) const { assert(l <= r && r <= n); return prod(root, 0, n, l, r); } S all_prod() const { return root ? root->product : e(); } void reset(ll l, ll r) { assert(l <= r && r <= n); return reset(root, 0, n, l, r); } template ll max_right(ll l) const { return max_right(l, [](S x) { return f(x); }); } template ll max_right(ll l, const F& f) const { assert(l <= n); S product = e(); assert(f(product)); return max_right(root, 0, n, l, f, product); } template ll min_left(ll r) const { return min_left(r, [](S x) { return f(x); }); } template ll min_left(ll r, const F& f) const { assert(r <= n); S product = e(); assert(f(product)); return min_left(root, 0, n, r, f, product); } private: struct node; using node_ptr = std::unique_ptr; struct node { ll index; S value, product; node_ptr left, right; node(ll index, S value) : index(index), value(value), product(value), left(nullptr), right(nullptr) {} void update() { product = op(op(left ? left->product : e(), value), right ? right->product : e()); } }; const ll n; node_ptr root; void set(node_ptr& t, ll a, ll b, ll p, S x) const { if (!t) { t = std::make_unique(p, x); return; } if (t->index == p) { t->value = x; t->update(); return; } ll c = (a + b) >> 1; if (p < c) { if (t->index < p) std::swap(t->index, p), std::swap(t->value, x); set(t->left, a, c, p, x); } else { if (p < t->index) std::swap(p, t->index), std::swap(x, t->value); set(t->right, c, b, p, x); } t->update(); } S get(const node_ptr& t, ll a, ll b, ll p) const { if (!t) return e(); if (t->index == p) return t->value; ll c = (a + b) >> 1; if (p < c) return get(t->left, a, c, p); else return get(t->right, c, b, p); } S prod(const node_ptr& t, ll a, ll b, ll l, ll r) const { if (!t || b <= l || r <= a) return e(); if (l <= a && b <= r) return t->product; ll c = (a + b) >> 1; S result = prod(t->left, a, c, l, r); if (l <= t->index && t->index < r) result = op(result, t->value); return op(result, prod(t->right, c, b, l, r)); } void reset(node_ptr& t, ll a, ll b, ll l, ll r) const { if (!t || b <= l || r <= a) return; if (l <= a && b <= r) { t.reset(); return; } ll c = (a + b) >> 1; reset(t->left, a, c, l, r); reset(t->right, c, b, l, r); t->update(); } template ll max_right(const node_ptr& t, ll a, ll b, ll l, const F& f, S& product) const { if (!t || b <= l) return n; if (f(op(product, t->product))) { product = op(product, t->product); return n; } ll c = (a + b) >> 1; ll result = max_right(t->left, a, c, l, f, product); if (result != n) return result; if (l <= t->index) { product = op(product, t->value); if (!f(product)) return t->index; } return max_right(t->right, c, b, l, f, product); } template ll min_left(const node_ptr& t, ll a, ll b, ll r, const F& f, S& product) const { if (!t || r <= a) return 0; if (f(op(t->product, product))) { product = op(t->product, product); return 0; } ll c = (a + b) >> 1; ll result = min_left(t->right, c, b, r, f, product); if (result != 0) return result; if (t->index < r) { product = op(t->value, product); if (!f(product)) return t->index + 1; } return min_left(t->left, a, c, r, f, product); } }; struct S{ll cnt,sum,kind;}; S op(S a,S b){return {a.cnt+b.cnt,a.sum+b.sum,a.kind+b.kind};} S e(){return {0,0,0}; } class multiset_{ private: dynamic_segtree seg; ll mx,mn,MX,geta; int size_,sum_; public: multiset_(ll mx=1e18,ll mn=-1e18):mx(mx),mn(mn),MX((mx+1)-(mn-1)),seg((mx+1)-(mn-1)),geta(-(mn-1)),size_(0),sum_(0){} ll size()const{return size_;} ll sum()const{return sum_;} ll kind()const{return seg.all_prod().kind;} void insert(ll v,ll k=1){ v += geta; auto [c,s,_] = seg.get(v); seg.set(v,{c+k,s+(v-geta)*k,c+k>0}); size_ += k; sum_ += (v-geta)*k; } void erase(ll v,ll k=1){ auto [c,s,_] = seg.get(v+geta); assert(k<=c); insert(v,-k); } ll count(ll v){ return seg.get(v+geta).cnt; } ll high_sum(ll k){ if(size_k); auto f = [k](S s){return s.cnt <= k;}; auto r = seg.max_right(0,f); return r-geta; } ll operator [](ll k) const{ assert(k>y[i]; multiset_ st; rep(i,n)st.insert(i); rep(_,n-1){ INT(s); --s; int l = st[s]; st.erase(l); int r = st[st.lower_bound(l+1)]; if(y[l]=="and"){ x[r] = x[l] & x[r]; } if(y[l]=="or"){ x[r] = x[l] | x[r]; } if(y[l]=="xor"){ x[r] = x[l] ^ x[r]; } if(y[l]=="imp"){ x[r] = x[l]<=x[r]; } } print(x[st[0]]?"True":"False"); } return 0; }