#include <bits/stdc++.h>
using namespace std;
string f[300];
char s[300];
int main() {
  f[0] = "!x&x";
  f[1] = "x&y&z";
  f[2] = "!z&x&y";
  f[3] = "x&y";
  f[4] = "!y&x&z";
  f[5] = "x&z";
  f[6] = "!y&x&z|!z&x&y";
  f[7] = "(y|z)&x";
  f[8] = "!y&!z&x";
  f[9] = "!y&!z&x|x&y&z";
  f[10] = "!z&x";
  f[11] = "!z&x|x&y";
  f[12] = "!y&x";
  f[13] = "!y&x|x&z";
  f[14] = "!(y&z)&x";
  f[15] = "x";
  f[16] = "!x&y&z";
  f[17] = "y&z";
  f[18] = "!x&y&z|!z&x&y";
  f[19] = "(x|z)&y";
  f[20] = "!x&y&z|!y&x&z";
  f[21] = "(x|y)&z";
  f[22] = "!x&y&z|!y&x&z|!z&x&y";
  f[23] = "(x|y)&z|x&y";
  f[24] = "!x&y&z|!y&!z&x";
  f[25] = "!y&!z&x|y&z";
  f[26] = "!x&y&z|!z&x";
  f[27] = "!z&x|y&z";
  f[28] = "!x&y&z|!y&x";
  f[29] = "!y&x|y&z";
  f[30] = "!(y&z)&x|!x&y&z";
  f[31] = "x|y&z";
  f[32] = "!x&!z&y";
  f[33] = "!x&!z&y|x&y&z";
  f[34] = "!z&y";
  f[35] = "!z&y|x&y";
  f[36] = "!x&!z&y|!y&x&z";
  f[37] = "!x&!z&y|x&z";
  f[38] = "!y&x&z|!z&y";
  f[39] = "!z&y|x&z";
  f[40] = "!(!x&!y|x&y|z)";
  f[41] = "!(!x&!y|x&y|z)|x&y&z";
  f[42] = "!z&(x|y)";
  f[43] = "!z&(x|y)|x&y";
  f[44] = "!x&!z&y|!y&x";
  f[45] = "!x&!z&y|!y&x|x&z";
  f[46] = "!y&x|!z&y";
  f[47] = "!z&y|x";
  f[48] = "!x&y";
  f[49] = "!x&y|y&z";
  f[50] = "!(x&z)&y";
  f[51] = "y";
  f[52] = "!x&y|!y&x&z";
  f[53] = "!x&y|x&z";
  f[54] = "!(x&z)&y|!y&x&z";
  f[55] = "x&z|y";
  f[56] = "!x&y|!y&!z&x";
  f[57] = "!x&y|!y&!z&x|y&z";
  f[58] = "!x&y|!z&x";
  f[59] = "!z&x|y";
  f[60] = "!x&y|!y&x";
  f[61] = "!x&y|!y&x|x&z";
  f[62] = "!(x&z)&y|!y&x";
  f[63] = "x|y";
  f[64] = "!x&!y&z";
  f[65] = "!x&!y&z|x&y&z";
  f[66] = "!x&!y&z|!z&x&y";
  f[67] = "!x&!y&z|x&y";
  f[68] = "!y&z";
  f[69] = "!y&z|x&z";
  f[70] = "!y&z|!z&x&y";
  f[71] = "!y&z|x&y";
  f[72] = "!(!x&!z|x&z|y)";
  f[73] = "!(!x&!z|x&z|y)|x&y&z";
  f[74] = "!x&!y&z|!z&x";
  f[75] = "!x&!y&z|!z&x|x&y";
  f[76] = "!y&(x|z)";
  f[77] = "!y&(x|z)|x&z";
  f[78] = "!y&z|!z&x";
  f[79] = "!y&z|x";
  f[80] = "!x&z";
  f[81] = "!x&z|y&z";
  f[82] = "!x&z|!z&x&y";
  f[83] = "!x&z|x&y";
  f[84] = "!(x&y)&z";
  f[85] = "z";
  f[86] = "!(x&y)&z|!z&x&y";
  f[87] = "x&y|z";
  f[88] = "!x&z|!y&!z&x";
  f[89] = "!x&z|!y&!z&x|y&z";
  f[90] = "!x&z|!z&x";
  f[91] = "!x&z|!z&x|x&y";
  f[92] = "!x&z|!y&x";
  f[93] = "!y&x|z";
  f[94] = "!(x&y)&z|!z&x";
  f[95] = "x|z";
  f[96] = "!(!y&!z|x|y&z)";
  f[97] = "!(!y&!z|x|y&z)|x&y&z";
  f[98] = "!x&!y&z|!z&y";
  f[99] = "!x&!y&z|!z&y|x&y";
  f[100] = "!x&!z&y|!y&z";
  f[101] = "!x&!z&y|!y&z|x&z";
  f[102] = "!y&z|!z&y";
  f[103] = "!y&z|!z&y|x&y";
  f[104] = "!(!x&!y|x&y|z)|!x&!y&z";
  f[105] = "!(!x&!y|x&y|z)|!x&!y&z|x&y&z";
  f[106] = "!x&!y&z|!z&(x|y)";
  f[107] = "!x&!y&z|!z&(x|y)|x&y";
  f[108] = "!x&!z&y|!y&(x|z)";
  f[109] = "!x&!z&y|!y&(x|z)|x&z";
  f[110] = "!y&(x|z)|!z&y";
  f[111] = "!y&z|!z&y|x";
  f[112] = "!x&(y|z)";
  f[113] = "!x&(y|z)|y&z";
  f[114] = "!x&z|!z&y";
  f[115] = "!x&z|y";
  f[116] = "!x&y|!y&z";
  f[117] = "!x&y|z";
  f[118] = "!(x&y)&z|!z&y";
  f[119] = "y|z";
  f[120] = "!x&(y|z)|!y&!z&x";
  f[121] = "!x&(y|z)|!y&!z&x|y&z";
  f[122] = "!x&(y|z)|!z&x";
  f[123] = "!x&z|!z&x|y";
  f[124] = "!x&(y|z)|!y&x";
  f[125] = "!x&y|!y&x|z";
  f[126] = "!x&y|!y&z|!z&x";
  f[127] = "x|y|z";
  f[128] = "!(x|y|z)";
  f[129] = "!(x|y|z)|x&y&z";
  f[130] = "!(!x&y|!y&x|z)";
  f[131] = "!(x|y|z)|x&y";
  f[132] = "!(!x&z|!z&x|y)";
  f[133] = "!(x|y|z)|x&z";
  f[134] = "!(!x&y|!y&x|z)|!y&x&z";
  f[135] = "!(x|y|z)|(y|z)&x";
  f[136] = "!y&!z";
  f[137] = "!y&!z|x&y&z";
  f[138] = "!(!x&y|z)";
  f[139] = "!y&!z|x&y";
  f[140] = "!(!x&z|y)";
  f[141] = "!y&!z|x&z";
  f[142] = "!(!x&y|z)|!y&x";
  f[143] = "!y&!z|x";
  f[144] = "!(!y&z|!z&y|x)";
  f[145] = "!(x|y|z)|y&z";
  f[146] = "!(!x&y|!y&x|z)|!x&y&z";
  f[147] = "!(x|y|z)|(x|z)&y";
  f[148] = "!(!x&z|!z&x|y)|!x&y&z";
  f[149] = "!(x|y|z)|(x|y)&z";
  f[150] = "!(!x&y|!y&x|z)|!x&y&z|!y&x&z";
  f[151] = "!(x|y|z)|(x|y)&z|x&y";
  f[152] = "!x&y&z|!y&!z";
  f[153] = "!y&!z|y&z";
  f[154] = "!(!x&y|z)|!x&y&z";
  f[155] = "!(!x&y|z)|y&z";
  f[156] = "!(!x&z|y)|!x&y&z";
  f[157] = "!(!x&z|y)|y&z";
  f[158] = "!(!x&y|z)|!x&y&z|!y&x";
  f[159] = "!y&!z|x|y&z";
  f[160] = "!x&!z";
  f[161] = "!x&!z|x&y&z";
  f[162] = "!(!y&x|z)";
  f[163] = "!x&!z|x&y";
  f[164] = "!x&!z|!y&x&z";
  f[165] = "!x&!z|x&z";
  f[166] = "!(!y&x|z)|!y&x&z";
  f[167] = "!(!y&x|z)|x&z";
  f[168] = "!(x&y|z)";
  f[169] = "!(x&y|z)|x&y&z";
  f[170] = "!z";
  f[171] = "!z|x&y";
  f[172] = "!x&!z|!y&x";
  f[173] = "!(x&y|z)|x&z";
  f[174] = "!y&x|!z";
  f[175] = "!z|x";
  f[176] = "!(!y&z|x)";
  f[177] = "!x&!z|y&z";
  f[178] = "!(!y&x|z)|!x&y";
  f[179] = "!x&!z|y";
  f[180] = "!(!y&z|x)|!y&x&z";
  f[181] = "!(!y&z|x)|x&z";
  f[182] = "!(!y&x|z)|!x&y|!y&x&z";
  f[183] = "!x&!z|x&z|y";
  f[184] = "!x&y|!y&!z";
  f[185] = "!(x&y|z)|y&z";
  f[186] = "!x&y|!z";
  f[187] = "!z|y";
  f[188] = "!(!x&!y&z|x&y)";
  f[189] = "!x&!z|!y&x|y&z";
  f[190] = "!x&y|!y&x|!z";
  f[191] = "!z|x|y";
  f[192] = "!x&!y";
  f[193] = "!x&!y|x&y&z";
  f[194] = "!x&!y|!z&x&y";
  f[195] = "!x&!y|x&y";
  f[196] = "!(!z&x|y)";
  f[197] = "!x&!y|x&z";
  f[198] = "!(!z&x|y)|!z&x&y";
  f[199] = "!(!z&x|y)|x&y";
  f[200] = "!(x&z|y)";
  f[201] = "!(x&z|y)|x&y&z";
  f[202] = "!x&!y|!z&x";
  f[203] = "!(x&z|y)|x&y";
  f[204] = "!y";
  f[205] = "!y|x&z";
  f[206] = "!y|!z&x";
  f[207] = "!y|x";
  f[208] = "!(!z&y|x)";
  f[209] = "!x&!y|y&z";
  f[210] = "!(!z&y|x)|!z&x&y";
  f[211] = "!(!z&y|x)|x&y";
  f[212] = "!(!z&x|y)|!x&z";
  f[213] = "!x&!y|z";
  f[214] = "!(!z&x|y)|!x&z|!z&x&y";
  f[215] = "!x&!y|x&y|z";
  f[216] = "!x&z|!y&!z";
  f[217] = "!(x&z|y)|y&z";
  f[218] = "!(!x&!z&y|x&z)";
  f[219] = "!x&!y|!z&x|y&z";
  f[220] = "!x&z|!y";
  f[221] = "!y|z";
  f[222] = "!x&z|!y|!z&x";
  f[223] = "!y|x|z";
  f[224] = "!(x|y&z)";
  f[225] = "!(x|y&z)|x&y&z";
  f[226] = "!x&!y|!z&y";
  f[227] = "!(x|y&z)|x&y";
  f[228] = "!x&!z|!y&z";
  f[229] = "!(x|y&z)|x&z";
  f[230] = "!(!y&!z&x|y&z)";
  f[231] = "!x&!y|!z&y|x&z";
  f[232] = "!((x|y)&z|x&y)";
  f[233] = "!((x|y)&z|x&y)|x&y&z";
  f[234] = "!x&!y|!z";
  f[235] = "!x&!y|!z|x&y";
  f[236] = "!x&!z|!y";
  f[237] = "!x&!z|!y|x&z";
  f[238] = "!y|!z";
  f[239] = "!y|!z|x";
  f[240] = "!x";
  f[241] = "!x|y&z";
  f[242] = "!x|!z&y";
  f[243] = "!x|y";
  f[244] = "!x|!y&z";
  f[245] = "!x|z";
  f[246] = "!x|!y&z|!z&y";
  f[247] = "!x|y|z";
  f[248] = "!x|!y&!z";
  f[249] = "!x|!y&!z|y&z";
  f[250] = "!x|!z";
  f[251] = "!x|!z|y";
  f[252] = "!x|!y";
  f[253] = "!x|!y|z";
  f[254] = "!(x&y&z)";
  f[255] = "!x|x";
  int n;
  scanf("%d", &n);
  while (n--) {
    scanf("%s", s);
    int t = 0;
    for (int i = 0; i <= 7; ++i) t = t * 2 + (s[i] == '1');
    cout << f[t] << '\n';
  }
}

### Prompt

Please formulate a Cpp solution to the following problem:

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>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string f[300];
char s[300];
int main() {
  f[0] = "!x&x";
  f[1] = "x&y&z";
  f[2] = "!z&x&y";
  f[3] = "x&y";
  f[4] = "!y&x&z";
  f[5] = "x&z";
  f[6] = "!y&x&z|!z&x&y";
  f[7] = "(y|z)&x";
  f[8] = "!y&!z&x";
  f[9] = "!y&!z&x|x&y&z";
  f[10] = "!z&x";
  f[11] = "!z&x|x&y";
  f[12] = "!y&x";
  f[13] = "!y&x|x&z";
  f[14] = "!(y&z)&x";
  f[15] = "x";
  f[16] = "!x&y&z";
  f[17] = "y&z";
  f[18] = "!x&y&z|!z&x&y";
  f[19] = "(x|z)&y";
  f[20] = "!x&y&z|!y&x&z";
  f[21] = "(x|y)&z";
  f[22] = "!x&y&z|!y&x&z|!z&x&y";
  f[23] = "(x|y)&z|x&y";
  f[24] = "!x&y&z|!y&!z&x";
  f[25] = "!y&!z&x|y&z";
  f[26] = "!x&y&z|!z&x";
  f[27] = "!z&x|y&z";
  f[28] = "!x&y&z|!y&x";
  f[29] = "!y&x|y&z";
  f[30] = "!(y&z)&x|!x&y&z";
  f[31] = "x|y&z";
  f[32] = "!x&!z&y";
  f[33] = "!x&!z&y|x&y&z";
  f[34] = "!z&y";
  f[35] = "!z&y|x&y";
  f[36] = "!x&!z&y|!y&x&z";
  f[37] = "!x&!z&y|x&z";
  f[38] = "!y&x&z|!z&y";
  f[39] = "!z&y|x&z";
  f[40] = "!(!x&!y|x&y|z)";
  f[41] = "!(!x&!y|x&y|z)|x&y&z";
  f[42] = "!z&(x|y)";
  f[43] = "!z&(x|y)|x&y";
  f[44] = "!x&!z&y|!y&x";
  f[45] = "!x&!z&y|!y&x|x&z";
  f[46] = "!y&x|!z&y";
  f[47] = "!z&y|x";
  f[48] = "!x&y";
  f[49] = "!x&y|y&z";
  f[50] = "!(x&z)&y";
  f[51] = "y";
  f[52] = "!x&y|!y&x&z";
  f[53] = "!x&y|x&z";
  f[54] = "!(x&z)&y|!y&x&z";
  f[55] = "x&z|y";
  f[56] = "!x&y|!y&!z&x";
  f[57] = "!x&y|!y&!z&x|y&z";
  f[58] = "!x&y|!z&x";
  f[59] = "!z&x|y";
  f[60] = "!x&y|!y&x";
  f[61] = "!x&y|!y&x|x&z";
  f[62] = "!(x&z)&y|!y&x";
  f[63] = "x|y";
  f[64] = "!x&!y&z";
  f[65] = "!x&!y&z|x&y&z";
  f[66] = "!x&!y&z|!z&x&y";
  f[67] = "!x&!y&z|x&y";
  f[68] = "!y&z";
  f[69] = "!y&z|x&z";
  f[70] = "!y&z|!z&x&y";
  f[71] = "!y&z|x&y";
  f[72] = "!(!x&!z|x&z|y)";
  f[73] = "!(!x&!z|x&z|y)|x&y&z";
  f[74] = "!x&!y&z|!z&x";
  f[75] = "!x&!y&z|!z&x|x&y";
  f[76] = "!y&(x|z)";
  f[77] = "!y&(x|z)|x&z";
  f[78] = "!y&z|!z&x";
  f[79] = "!y&z|x";
  f[80] = "!x&z";
  f[81] = "!x&z|y&z";
  f[82] = "!x&z|!z&x&y";
  f[83] = "!x&z|x&y";
  f[84] = "!(x&y)&z";
  f[85] = "z";
  f[86] = "!(x&y)&z|!z&x&y";
  f[87] = "x&y|z";
  f[88] = "!x&z|!y&!z&x";
  f[89] = "!x&z|!y&!z&x|y&z";
  f[90] = "!x&z|!z&x";
  f[91] = "!x&z|!z&x|x&y";
  f[92] = "!x&z|!y&x";
  f[93] = "!y&x|z";
  f[94] = "!(x&y)&z|!z&x";
  f[95] = "x|z";
  f[96] = "!(!y&!z|x|y&z)";
  f[97] = "!(!y&!z|x|y&z)|x&y&z";
  f[98] = "!x&!y&z|!z&y";
  f[99] = "!x&!y&z|!z&y|x&y";
  f[100] = "!x&!z&y|!y&z";
  f[101] = "!x&!z&y|!y&z|x&z";
  f[102] = "!y&z|!z&y";
  f[103] = "!y&z|!z&y|x&y";
  f[104] = "!(!x&!y|x&y|z)|!x&!y&z";
  f[105] = "!(!x&!y|x&y|z)|!x&!y&z|x&y&z";
  f[106] = "!x&!y&z|!z&(x|y)";
  f[107] = "!x&!y&z|!z&(x|y)|x&y";
  f[108] = "!x&!z&y|!y&(x|z)";
  f[109] = "!x&!z&y|!y&(x|z)|x&z";
  f[110] = "!y&(x|z)|!z&y";
  f[111] = "!y&z|!z&y|x";
  f[112] = "!x&(y|z)";
  f[113] = "!x&(y|z)|y&z";
  f[114] = "!x&z|!z&y";
  f[115] = "!x&z|y";
  f[116] = "!x&y|!y&z";
  f[117] = "!x&y|z";
  f[118] = "!(x&y)&z|!z&y";
  f[119] = "y|z";
  f[120] = "!x&(y|z)|!y&!z&x";
  f[121] = "!x&(y|z)|!y&!z&x|y&z";
  f[122] = "!x&(y|z)|!z&x";
  f[123] = "!x&z|!z&x|y";
  f[124] = "!x&(y|z)|!y&x";
  f[125] = "!x&y|!y&x|z";
  f[126] = "!x&y|!y&z|!z&x";
  f[127] = "x|y|z";
  f[128] = "!(x|y|z)";
  f[129] = "!(x|y|z)|x&y&z";
  f[130] = "!(!x&y|!y&x|z)";
  f[131] = "!(x|y|z)|x&y";
  f[132] = "!(!x&z|!z&x|y)";
  f[133] = "!(x|y|z)|x&z";
  f[134] = "!(!x&y|!y&x|z)|!y&x&z";
  f[135] = "!(x|y|z)|(y|z)&x";
  f[136] = "!y&!z";
  f[137] = "!y&!z|x&y&z";
  f[138] = "!(!x&y|z)";
  f[139] = "!y&!z|x&y";
  f[140] = "!(!x&z|y)";
  f[141] = "!y&!z|x&z";
  f[142] = "!(!x&y|z)|!y&x";
  f[143] = "!y&!z|x";
  f[144] = "!(!y&z|!z&y|x)";
  f[145] = "!(x|y|z)|y&z";
  f[146] = "!(!x&y|!y&x|z)|!x&y&z";
  f[147] = "!(x|y|z)|(x|z)&y";
  f[148] = "!(!x&z|!z&x|y)|!x&y&z";
  f[149] = "!(x|y|z)|(x|y)&z";
  f[150] = "!(!x&y|!y&x|z)|!x&y&z|!y&x&z";
  f[151] = "!(x|y|z)|(x|y)&z|x&y";
  f[152] = "!x&y&z|!y&!z";
  f[153] = "!y&!z|y&z";
  f[154] = "!(!x&y|z)|!x&y&z";
  f[155] = "!(!x&y|z)|y&z";
  f[156] = "!(!x&z|y)|!x&y&z";
  f[157] = "!(!x&z|y)|y&z";
  f[158] = "!(!x&y|z)|!x&y&z|!y&x";
  f[159] = "!y&!z|x|y&z";
  f[160] = "!x&!z";
  f[161] = "!x&!z|x&y&z";
  f[162] = "!(!y&x|z)";
  f[163] = "!x&!z|x&y";
  f[164] = "!x&!z|!y&x&z";
  f[165] = "!x&!z|x&z";
  f[166] = "!(!y&x|z)|!y&x&z";
  f[167] = "!(!y&x|z)|x&z";
  f[168] = "!(x&y|z)";
  f[169] = "!(x&y|z)|x&y&z";
  f[170] = "!z";
  f[171] = "!z|x&y";
  f[172] = "!x&!z|!y&x";
  f[173] = "!(x&y|z)|x&z";
  f[174] = "!y&x|!z";
  f[175] = "!z|x";
  f[176] = "!(!y&z|x)";
  f[177] = "!x&!z|y&z";
  f[178] = "!(!y&x|z)|!x&y";
  f[179] = "!x&!z|y";
  f[180] = "!(!y&z|x)|!y&x&z";
  f[181] = "!(!y&z|x)|x&z";
  f[182] = "!(!y&x|z)|!x&y|!y&x&z";
  f[183] = "!x&!z|x&z|y";
  f[184] = "!x&y|!y&!z";
  f[185] = "!(x&y|z)|y&z";
  f[186] = "!x&y|!z";
  f[187] = "!z|y";
  f[188] = "!(!x&!y&z|x&y)";
  f[189] = "!x&!z|!y&x|y&z";
  f[190] = "!x&y|!y&x|!z";
  f[191] = "!z|x|y";
  f[192] = "!x&!y";
  f[193] = "!x&!y|x&y&z";
  f[194] = "!x&!y|!z&x&y";
  f[195] = "!x&!y|x&y";
  f[196] = "!(!z&x|y)";
  f[197] = "!x&!y|x&z";
  f[198] = "!(!z&x|y)|!z&x&y";
  f[199] = "!(!z&x|y)|x&y";
  f[200] = "!(x&z|y)";
  f[201] = "!(x&z|y)|x&y&z";
  f[202] = "!x&!y|!z&x";
  f[203] = "!(x&z|y)|x&y";
  f[204] = "!y";
  f[205] = "!y|x&z";
  f[206] = "!y|!z&x";
  f[207] = "!y|x";
  f[208] = "!(!z&y|x)";
  f[209] = "!x&!y|y&z";
  f[210] = "!(!z&y|x)|!z&x&y";
  f[211] = "!(!z&y|x)|x&y";
  f[212] = "!(!z&x|y)|!x&z";
  f[213] = "!x&!y|z";
  f[214] = "!(!z&x|y)|!x&z|!z&x&y";
  f[215] = "!x&!y|x&y|z";
  f[216] = "!x&z|!y&!z";
  f[217] = "!(x&z|y)|y&z";
  f[218] = "!(!x&!z&y|x&z)";
  f[219] = "!x&!y|!z&x|y&z";
  f[220] = "!x&z|!y";
  f[221] = "!y|z";
  f[222] = "!x&z|!y|!z&x";
  f[223] = "!y|x|z";
  f[224] = "!(x|y&z)";
  f[225] = "!(x|y&z)|x&y&z";
  f[226] = "!x&!y|!z&y";
  f[227] = "!(x|y&z)|x&y";
  f[228] = "!x&!z|!y&z";
  f[229] = "!(x|y&z)|x&z";
  f[230] = "!(!y&!z&x|y&z)";
  f[231] = "!x&!y|!z&y|x&z";
  f[232] = "!((x|y)&z|x&y)";
  f[233] = "!((x|y)&z|x&y)|x&y&z";
  f[234] = "!x&!y|!z";
  f[235] = "!x&!y|!z|x&y";
  f[236] = "!x&!z|!y";
  f[237] = "!x&!z|!y|x&z";
  f[238] = "!y|!z";
  f[239] = "!y|!z|x";
  f[240] = "!x";
  f[241] = "!x|y&z";
  f[242] = "!x|!z&y";
  f[243] = "!x|y";
  f[244] = "!x|!y&z";
  f[245] = "!x|z";
  f[246] = "!x|!y&z|!z&y";
  f[247] = "!x|y|z";
  f[248] = "!x|!y&!z";
  f[249] = "!x|!y&!z|y&z";
  f[250] = "!x|!z";
  f[251] = "!x|!z|y";
  f[252] = "!x|!y";
  f[253] = "!x|!y|z";
  f[254] = "!(x&y&z)";
  f[255] = "!x|x";
  int n;
  scanf("%d", &n);
  while (n--) {
    scanf("%s", s);
    int t = 0;
    for (int i = 0; i <= 7; ++i) t = t * 2 + (s[i] == '1');
    cout << f[t] << '\n';
  }
}

```