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.
/**
 * @author derrick20
 */

import java.io.*;
import java.util.*;

public class MarsRover implements Runnable {
    public static void main(String[] args) throws Exception {
        new Thread(null, new MarsRover(), ": )", 1 << 28).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        adjList = new ArrayList[N];
        Arrays.setAll(adjList, i -> new ArrayList<>());
        type = new String[N];
        val = new boolean[N];
        ArrayList<Integer> leaves = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            String t = sc.next();
            type[i] = t;
            if (t.equals("IN")) {
                val[i] = sc.nextInt() == 1;
                leaves.add(i);
            } else if (t.equals("NOT")) {
                adjList[i].add(sc.nextInt() - 1);
            } else {
                int u = sc.nextInt() - 1;
                int v = sc.nextInt() - 1;
                adjList[i].add(u);
                adjList[i].add(v);
            }
        }

        compute(0);
        toggle = new boolean[N];
        setup(0, -1, -1);
//        System.out.println("Val: " + Arrays.toString(val));
//        System.out.println("Toggle: " + Arrays.toString(toggle));
        StringBuilder ans = new StringBuilder();
        for (int leaf : leaves) {
            boolean flip = toggle[leaf];
//            System.out.println("Leaf " + leaf + " toggle = " + toggle[leaf]);
            ans.append(flip ^ val[0] ? 1 : 0);
        }
        out.println(ans);
        out.close();
    }

    static String[] type;
    static boolean[] toggle;
    static boolean[] val;
    static ArrayList<Integer>[] adjList;

    static void setup(int node, int par, int idx) {
        if (par != -1) {
            if (type[par].equals("NOT") || type[par].equals("XOR")) {
                toggle[node] = true;
            } else {
                int sibling = adjList[par].get(1 - idx);
                if (type[par].equals("AND") && val[sibling]) {
                    toggle[node] = true;
                } else if (type[par].equals("OR") && !val[sibling]) {
                    toggle[node] = true;
                } else {
                    // if nothing could toggle it, we can't go any further
                    return;
                }
            }
//            System.out.println("From " + par + " to " + node + " toggles = " + toggle[par] + " -> " + toggle[node]);
        }
        for (int i = 0; i < adjList[node].size(); i++) {
            setup(adjList[node].get(i), node, i);
        }
    }

    static boolean compute(int node) {
        if (type[node].equals("IN")) {
            return val[node];
        } else if (type[node].equals("NOT")) {
            return val[node] = !compute(adjList[node].get(0));
        } else {
            boolean v1 = compute(adjList[node].get(0));
            boolean v2 = compute(adjList[node].get(1));
            if (type[node].equals("AND")) {
                val[node] = v1 & v2;
            } else if (type[node].equals("OR")) {
                val[node] = v1 | v2;
            } else {
                val[node] = v1 ^ v2;
            }
            return val[node];
        }
    }

    static class FastScanner {
        private int BS = 1 << 16;
        private char NC = (char) 0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            } catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt = 1;
            boolean neg = false;
            if (c == NC) c = getChar();
            for (; (c < '0' || c > '9'); c = getChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = getChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                cnt *= 10;
            }
            return neg ? -res : res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c != '.' ? cur : cur + nextLong() / cnt;
        }

        public double[] nextDoubles(int N) {
            double[] res = new double[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextDouble();
            }
            return res;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c > 32) {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c != '\n') {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if (c > 32) return true;
            while (true) {
                c = getChar();
                if (c == NC) return false;
                else if (c > 32) return true;
            }
        }
    }

    static void ASSERT(boolean assertion, String message) {
        if (!assertion) throw new AssertionError(message);
    }

    static void ASSERT(boolean assertion) {
        if (!assertion) throw new AssertionError();
    }
}