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.
AND = "AND"
OR = "OR"
XOR = "XOR"
NOT = "NOT"
IN = "IN"

OPS = {
    AND: AND,
    OR: OR,
    XOR: XOR,
    NOT: NOT,
}


class Node:
    def __init__(self, num):
        self.num = num
        self.op = None
        self.parent = None
        self.input_1 = None
        self.input_2 = None
        self.orig_value = None
        self.root_value_if_changed = None

    @property
    def children(self):
        if self.op == IN:
            return []
        elif self.op == NOT:
            return [self.input_1]
        else:
            return [self.input_1, self.input_2]

    def can_compute(self):
        if self.op == IN:
            return True

        if self.op == NOT:
            return self.input_1.orig_value is not None

        return self.input_1.orig_value is not None and self.input_2.orig_value is not None

    def compute(self):
        if self.op == IN:
            return self.orig_value

        assert self.can_compute()

        if self.op == NOT:
            return not self.input_1.orig_value
        elif self.op == AND:
            return self.input_1.orig_value and self.input_2.orig_value
        elif self.op == OR:
            return self.input_1.orig_value or self.input_2.orig_value
        else:
            return self.input_1.orig_value != self.input_2.orig_value

    def set_input(self, a):
        self.input_1 = a
        a.parent = self

    def set_inputs(self, a, b):
        self.input_1 = a
        self.input_2 = b

        a.parent = self
        b.parent = self


def compute_orig_values(root):
    stack = [root]

    while len(stack) > 0:
        node: Node = stack[-1]

        if node.can_compute():
            node.orig_value = node.compute()
            stack.pop()
        else:
            stack.extend(node.children)


def compute_if_change(root: Node):
    def comp_if_changed(node: Node):
        if node is root:
            return not node.orig_value

        orig = node.orig_value
        node.orig_value = not node.orig_value
        res = node.parent.compute()
        node.orig_value = orig

        if res == node.parent.orig_value:
            return root.orig_value
        else:
            return node.parent.root_value_if_changed

    stack = [root]

    while len(stack) > 0:
        node: Node = stack.pop()

        node.root_value_if_changed = comp_if_changed(node)

        stack.extend(node.children)


def main():
    import sys

    n = int(sys.stdin.readline())

    nodes = {i: Node(i) for i in range(1, n + 1)}
    assert len(nodes) == n

    for i in range(1, n + 1):
        toks = sys.stdin.readline().strip().split(" ")

        node = nodes[i]

        if len(toks) == 2:
            if toks[0] == IN:
                node.op = IN
                node.orig_value = toks[1] == "1"
            else:
                node.op = NOT
                node.set_input(nodes[int(toks[1])])
        else:
            node.op = OPS[toks[0]]
            a, b = map(int, toks[1:])
            a = nodes[a]
            b = nodes[b]

            node.set_inputs(a, b)

    root: Node = nodes[1]

    compute_orig_values(root)
    compute_if_change(root)

    ret = []

    for i in range(1, n + 1):
        node = nodes[i]

        if node.op == IN:
            ret.append(int(node.root_value_if_changed))

    ret = "".join(str(x) for x in ret)
    print(ret)


if __name__ == '__main__':
    main()
