1010_D. Mars rover
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex 1, in which every leaf (excluding root) is an input, and all other vertices are logical elements, including the root, which is output. One bit is fed to each input. One bit is returned at the output.

There are four types of logical elements: [AND](https://en.wikipedia.org/wiki/Logical_conjunction) (2 inputs), [OR](https://en.wikipedia.org/wiki/Logical_disjunction) (2 inputs), [XOR](https://en.wikipedia.org/wiki/Exclusive_or) (2 inputs), [NOT](https://en.wikipedia.org/wiki/Negation) (1 input). Logical elements take values from their direct descendants (inputs) and return the result of the function they perform. Natasha knows the logical scheme of the Mars rover, as well as the fact that only one input is broken. In order to fix the Mars rover, she needs to change the value on this input.

For each input, determine what the output will be if Natasha changes this input.

Input

The first line contains a single integer n (2 ≤ n ≤ 10^6) — the number of vertices in the graph (both inputs and elements).

The i-th of the next n lines contains a description of i-th vertex: the first word "AND", "OR", "XOR", "NOT" or "IN" (means the input of the scheme) is the vertex type. If this vertex is "IN", then the value of this input follows (0 or 1), otherwise follow the indices of input vertices of this element: "AND", "OR", "XOR" have 2 inputs, whereas "NOT" has 1 input. The vertices are numbered from one.

It is guaranteed that input data contains a correct logical scheme with an output produced by the vertex 1.

Output

Print a string of characters '0' and '1' (without quotes) — answers to the problem for each input in the ascending order of their vertex indices.

Example

Input

10
AND 9 4
IN 1
IN 1
XOR 6 5
AND 3 7
IN 0
NOT 10
IN 1
IN 1
AND 2 8


Output

10110

Note

The original scheme from the example (before the input is changed):

<image>

Green indicates bits '1', yellow indicates bits '0'.

If Natasha changes the input bit 2 to 0, then the output will be 1.

If Natasha changes the input bit 3 to 0, then the output will be 0.

If Natasha changes the input bit 6 to 1, then the output will be 1.

If Natasha changes the input bit 8 to 0, then the output will be 1.

If Natasha changes the input bit 9 to 0, then the output will be 0.
```python
import sys
input=sys.stdin.readline
n=int(input())
stack=[]
children=[]
for i in range(n):
  children.append([])
parent=[-1]*n
nodes=[-1]*n
inputs=[]
functions=[-1]*n
for i in range(n):
  a=list(map(str,input().split()))
  r=a[0]
  if r=='IN':
    stack.append((i,int(a[1])))
    inputs.append(i)
  elif r=='NOT':
    parent[int(a[1])-1]=i
    children[i].append(int(a[1])-1)
    functions[i]=1
  else:
    x1=int(a[1])-1
    x2=int(a[2])-1
    parent[x1]=i
    parent[x2]=i
    children[i].append(x1)
    children[i].append(x2)
    if r=='AND':
      functions[i]=2
    elif r=='XOR':
      functions[i]=3
    else:
      functions[i]=4
while stack:
  pos,val=stack.pop()
  
  nodes[pos]=val
  if pos==0:
    break
  r=parent[pos]
  flag=0
  values=[]
  for child in children[r]:
    values.append(nodes[child])
  if not -1 in values:
    if functions[r]==1:
      stack.append((r,1-values[0]))
    elif functions[r]==2:
      stack.append((r,values[0]&values[1]))
    elif functions[r]==3:
      stack.append((r,values[0]^values[1]))
    else:
      stack.append((r,values[0]|values[1]))
output=nodes[0]
stack=[0]
important=[0]*n
while stack:
  pos=stack.pop()
  important[pos]=1
  if functions[pos]==-1:
    continue
  q=children[pos]
  
  if functions[pos]==1:
    stack.append(q[0])
  elif functions[pos]==2:
    if nodes[pos]==1:
      stack.append(q[0])
      stack.append(q[1])
    else:
      if nodes[q[0]]==1 and nodes[q[1]]==0:
        stack.append(q[1])
      elif nodes[q[0]]==0 and nodes[q[1]]==1:
        stack.append(q[0])
  elif functions[pos]==3:
    stack.append(q[0])
    stack.append(q[1])
  else:
    if nodes[pos]==0:
      stack.append(q[0])
      stack.append(q[1])
    else:
      if nodes[q[0]]==1 and nodes[q[1]]==0:
        stack.append(q[0])
      elif nodes[q[0]]==0 and nodes[q[1]]==1:
        stack.append(q[1])
ans=[]
for i in inputs:
  if important[i]:
    ans.append(1-output)
  else:
    ans.append(output)
print(''.join(map(str,ans)))
```