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.io.PrintStream;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.StringJoiner;
import java.util.Map.Entry;
import java.io.BufferedReader;

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

  static class TaskE {
    SvLogger log = new SvLogger().setEnabled(false);
    HashMap<Integer, Map<Integer, String>> memE = new HashMap<>();
    HashMap<Integer, Map<Integer, String>> memT = new HashMap<>();
    HashMap<Integer, Map<Integer, String>> memF = new HashMap<>();

    void putIfBetter(Map<Integer, String> map, int descriptor, String formula) {
      String existingFormula = map.putIfAbsent(descriptor, formula);
      if (existingFormula == null) return;
      if (formula.length() < existingFormula.length() ||
          (formula.length() == existingFormula.length() && formula.compareTo(existingFormula) < 0)) {
        map.put(descriptor, formula); // overwrite
      }
    }

    Map<Integer, String> genE(int maxLen) {
      if (memE.containsKey(maxLen)) return memE.get(maxLen);

      Map<Integer, String> ret = new HashMap<>(genT(maxLen));
      if (maxLen >= 3) {
        for (int e = 1; e <= maxLen - 2; ++e) {
          Map<Integer, String> subexpsE = genE(e);
          Map<Integer, String> subexpsT = genT(maxLen - 1 - e);
          for (Map.Entry entry1 : subexpsE.entrySet()) {
            for (Map.Entry entry2 : subexpsT.entrySet()) {
              putIfBetter(ret,
                  (int) entry1.getKey() | (int) entry2.getKey(),
                  entry1.getValue() + "|" + entry2.getValue());
            }
          }
        }
      }

      memE.put(maxLen, ret);
      return ret;
    }

    Map<Integer, String> genT(int maxLen) {
      if (memT.containsKey(maxLen)) return memT.get(maxLen);

      Map<Integer, String> ret = new HashMap<>(genF(maxLen));
      if (maxLen >= 3) {
        for (int t = 1; t <= maxLen - 2; ++t) {
          Map<Integer, String> subexpsT = genT(t);
          Map<Integer, String> subexpsF = genF(maxLen - 1 - t);
          for (Map.Entry entry1 : subexpsT.entrySet()) {
            for (Map.Entry entry2 : subexpsF.entrySet()) {
              putIfBetter(ret,
                  (int) entry1.getKey() & (int) entry2.getKey(),
                  entry1.getValue() + "&" + entry2.getValue());
            }
          }
        }
      }

      memT.put(maxLen, ret);
      return ret;
    }

    Map<Integer, String> genF(int maxLen) {
      if (memF.containsKey(maxLen)) return memF.get(maxLen);

      Map<Integer, String> ret = new HashMap<>(3);
      if (maxLen >= 1) {
        ret.put(15, "x"); // 00001111 in decimal
        ret.put(51, "y"); // 00110011 in decimal
        ret.put(85, "z"); // 01010101 in decimal
      }
      if (maxLen >= 2) {
        Map<Integer, String> subexps = genF(maxLen - 1);
        for (Map.Entry<Integer, String> entry : subexps.entrySet()) {
          putIfBetter(ret, (~entry.getKey()) & ((1 << 8) - 1), "!" + entry.getValue());
        }
      }
      if (maxLen >= 3) {
        Map<Integer, String> subexps = genE(maxLen - 2);
        for (Map.Entry<Integer, String> entry : subexps.entrySet()) {
          putIfBetter(ret, entry.getKey(), "(" + entry.getValue() + ")");
        }
      }

      memF.put(maxLen, ret);
      return ret;
    }

    public void solve(int testNumber, InputStreamReader in, PrintWriter out) {
      // The limit is chosen so that it generates formulas for all the 256 descriptors.
      Map<Integer, String> formulas = genE(28);
      log.p(formulas);
      log.p(formulas.size());

      SvScanner sc = new SvScanner(in);
      int n = sc.nextInt();
      for (int i = 0; i < n; ++i) {
        String binary = sc.next();
        int descriptor = 0; // represent the descriptor via a bitmask
        for (int k = 0; k < 8; ++k) {
          if (binary.charAt(k) == '1') {
            descriptor |= 1 << (7 - k);
          }
        }
        out.println(formulas.get(descriptor));
      }
    }

  }

  static class SvLogger {
    private static final String MESSAGE_PREFIX = "> ";
    private boolean enabled = true;

    public SvLogger setEnabled(boolean enabled) {
      this.enabled = enabled;
      return this;
    }

    public void p(Object... args) {
      if (!enabled) {
        return;
      }
      StringJoiner joiner = new StringJoiner(" ");
      for (Object o : args) {
        joiner.add(o.toString());
      }
      System.out.println(MESSAGE_PREFIX + joiner.toString());
    }

  }

  static class SvScanner {
    private BufferedReader reader;
    private StringTokenizer tokenizer = new StringTokenizer("");

    public SvScanner(InputStreamReader in) {
      reader = new BufferedReader(in);
    }

    public String next() {
      try {
        while (!tokenizer.hasMoreTokens()) {
          String nextLine = reader.readLine();
          if (nextLine == null) {
            throw new IllegalStateException("next line is null");
          }
          tokenizer = new StringTokenizer(nextLine);
        }
        return tokenizer.nextToken();
      } catch (IOException e) {
        throw new IllegalStateException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

  }
}

