You are given a boolean function of three variables which is defined by its truth table. You need to find an expression of minimum length that equals to this function. The expression may consist of: 

  * Operation AND ('&', ASCII code 38) 
  * Operation OR ('|', ASCII code 124) 
  * Operation NOT ('!', ASCII code 33) 
  * Variables x, y and z (ASCII codes 120-122) 
  * Parentheses ('(', ASCII code 40, and ')', ASCII code 41) 



If more than one expression of minimum length exists, you should find the lexicographically smallest one.

Operations have standard priority. NOT has the highest priority, then AND goes, and OR has the lowest priority. The expression should satisfy the following grammar:

E ::= E '|' T | T

T ::= T '&' F | F

F ::= '!' F | '(' E ')' | 'x' | 'y' | 'z'

Input

The first line contains one integer n — the number of functions in the input (1 ≤ n ≤ 10 000).

The following n lines contain descriptions of functions, the i-th of them contains a string of length 8 that consists of digits 0 and 1 — the truth table of the i-th function. The digit on position j (0 ≤ j < 8) equals to the value of the function in case of <image>, <image> and <image>.

Output

You should output n lines, the i-th line should contain the expression of minimum length which equals to the i-th function. If there is more than one such expression, output the lexicographically smallest of them. Expressions should satisfy the given grammar and shouldn't contain white spaces.

Example

Input

4
00110011
00000111
11110000
00011111


Output

y
(y|z)&amp;x
!x
x|y&amp;z

Note

The truth table for the second function:

<image>
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Queue;
import java.util.LinkedList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author beginner1010
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        final int bits = 8;
        final int N = 1 << bits;
        Expression[][] ans;
        Queue<Expression> q = new LinkedList<>();

        void add(Expression exp) {
            if (ans[exp.priority][exp.value] == null || ans[exp.priority][exp.value].compareTo(exp) == 1) {
                ans[exp.priority][exp.value] = exp;
                q.add(exp);
            }
        }

        void findAll(int x, int y, int z) {
            ans = new Expression[3][N];
            add(new Expression("x", x, 2));
            add(new Expression("y", y, 2));
            add(new Expression("z", z, 2));
            while (!q.isEmpty()) {
                Expression e = q.poll();
                if (ans[e.priority][e.value].compareTo(e) != 0) continue;
                if (e.priority == 0) {
                    add(new Expression("(" + e.expression + ")", e.value, 2));
                    for (int i = 0; i < N; i++)
                        if (ans[0][i] != null) {
                            add(new Expression(e.expression + "|" + ans[0][i].expression, e.value | i, 0));
                            add(new Expression(ans[0][i].expression + "|" + e.expression, e.value | i, 0));
                        }
                } else {
                    add(new Expression(e.expression, e.value, e.priority - 1));
                    if (e.priority == 1) {
                        for (int i = 0; i < N; i++)
                            if (ans[1][i] != null) {
                                add(new Expression(e.expression + "&" + ans[1][i].expression, e.value & i, 1));
                                add(new Expression(ans[1][i].expression + "&" + e.expression, e.value & i, 1));
                            }
                    } else {
                        assert (e.priority == 2);
                        add(new Expression("!" + e.expression, (N - 1) ^ e.value, 2));
                    }
                }
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            findAll(15, 51, 85);
            int n = in.nextInt();
            for (int i = 0; i < n; i++) {
                String f = in.next();
                int val = 0;
                for (int j = 0; j < bits; j++)
                    if (f.charAt(j) == '1') {
                        val |= (1 << (bits - 1 - j));
                    }
                Expression best = null;
                for (int j = 0; j < 3; j++)
                    if (ans[j][val] != null) {
                        if (best == null || (best.compareTo(ans[j][val]) == 1)) {
                            best = ans[j][val];
                        }
                    }
                out.println(best.expression);
            }
        }

        class Expression implements Comparable<Expression> {
            String expression;
            int priority;
            int value;

            Expression(String _expression, int _value, int _priority) {
                this.expression = _expression;
                this.value = _value;
                this.priority = _priority;
            }


            public int compareTo(Expression o) {
                if (this.expression.length() != o.expression.length())
                    return this.expression.length() < o.expression.length() ? -1 : 1;
                int cmp = this.expression.compareTo(o.expression);
                if (cmp == 0) return 0;
                return cmp / Math.abs(cmp);
            }

        }

    }

    static class InputReader {
        InputStream is;
        private byte[] inbuf = new byte[1024];
        private int lenbuf = 0;
        private int ptrbuf = 0;
        static final int[] ints = new int[128];

        public InputReader(InputStream is) {
            for (int i = '0'; i <= '9'; i++) ints[i] = i - '0';
            this.is = is;
        }

        public int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = is.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public boolean isSpaceChar(int c) {
            return !(c >= 33 && c <= 126);
        }

        public int skip() {
            int b;
            while ((b = readByte()) != -1 && isSpaceChar(b)) ;
            return b;
        }

        public String next() {
            int b = skip();
            StringBuilder sb = new StringBuilder();
            while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = (num << 3) + (num << 1) + ints[b];
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

    }
}

