Problem: Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.

In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an arbitrary sequence of these operations with arbitrary constants from 0 to 1023. When the program is run, all operations are applied (in the given order) to the argument and in the end the result integer is returned.

Petya wrote a program in this language, but it turned out to be too long. Write a program in CALPAS that does the same thing as the Petya's program, and consists of no more than 5 lines. Your program should return the same integer as Petya's program for all arguments from 0 to 1023.

Input

The first line contains an integer n (1 ≤ n ≤ 5·105) — the number of lines.

Next n lines contain commands. A command consists of a character that represents the operation ("&", "|" or "^" for AND, OR or XOR respectively), and the constant xi 0 ≤ xi ≤ 1023.

Output

Output an integer k (0 ≤ k ≤ 5) — the length of your program.

Next k lines must contain commands in the same format as in the input.

Examples

Input

3
| 3
^ 2
| 1


Output

2
| 3
^ 2


Input

3
&amp; 1
&amp; 3
&amp; 5


Output

1
&amp; 1


Input

3
^ 1
^ 2
^ 3


Output

0

Note

You can read about bitwise operations in <https://en.wikipedia.org/wiki/Bitwise_operation>.

Second sample:

Let x be an input of the Petya's program. It's output is ((x&1)&3)&5 = x&(1&3&5) = x&1. So these two programs always give the same outputs.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
int n;
char op[500010];
int x[500010];
int an[10][2];
int a[5];
int b[5];
int b2[10][5];
int ok2;
int b3[5];
int ok;
int suc(int ii) {
  int i, j;
  int v;
  if (b[0] == 0 && b[1] == 0 && b[2] == 0 && b[3] == 0 && b[4] == 1) int oo = 1;
  for (i = 0; i < 2; i++) {
    v = i;
    for (j = 0; j < 5; j++) {
      if (a[j] == 0)
        v &= b[j];
      else if (a[j] == 1)
        v |= b[j];
      else
        v ^= b[j];
    }
    if ((v > 0 && an[ii][i] == 0) || (v == 0 && an[ii][i] > 0)) return 0;
  }
  return 1;
}
void srch2(int ii, int dep) {
  int i;
  if (ok2 == 1) return;
  if (dep == 5) {
    if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0 && a[4] == 1) {
      if (b[0] == 0 && b[1] == 0 && b[2] == 0 && b[3] == 0 && b[4] == 0)
        int oo = 1;
    }
    if (suc(ii)) {
      for (i = 0; i < 5; i++) b2[ii][i] = b[i];
      ok2 = 1;
    }
    return;
  }
  b[dep] = 0;
  srch2(ii, dep + 1);
  if (ok2 == 1) return;
  b[dep] = 1;
  srch2(ii, dep + 1);
}
int calc() {
  int i;
  for (i = 0; i < 10; i++) {
    ok2 = 0;
    srch2(i, 0);
    if (ok2 == 0) return 0;
  }
  return 1;
}
void srch(int dep) {
  int i;
  if (ok) return;
  if (dep == 5) {
    if (a[0] == 1 && a[1] == 2 && a[2] == 1 && a[3] == 1 && a[4] == 1) {
      int oo = 1;
    }
    if (calc()) ok = 1;
    return;
  }
  a[dep] = 0;
  srch(dep + 1);
  if (ok) return;
  a[dep] = 1;
  srch(dep + 1);
  if (ok) return;
  a[dep] = 2;
  srch(dep + 1);
}
void prt() {
  int i, j;
  int v;
  printf("5\n");
  for (i = 0; i < 5; i++) {
    for (j = 0; j < 10; j++) {
      b3[i] += (b2[j][i] << j);
    }
  }
  char c;
  for (i = 0; i < 5; i++) {
    if (a[i] == 0)
      c = '&';
    else if (a[i] == 1)
      c = '|';
    else
      c = '^';
    printf("%c %d\n", c, b3[i]);
  }
}
void solve() {
  int i, j, k;
  for (k = 0; k < 10; k++) {
    for (i = 0; i < 2; i++) {
      int v = i;
      for (j = 0; j < n; j++) {
        if (op[j] == '&')
          v &= (x[j] >> k);
        else if (op[j] == '|')
          v |= (x[j] >> k);
        else
          v ^= (x[j] >> k);
      }
      if ((v & 1) > 0)
        an[k][i] = 1;
      else
        an[k][i] = 0;
    }
  }
  ok = 0;
  srch(0);
  prt();
}
int main() {
  int i;
  char s[5];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", s);
    op[i] = s[0];
    scanf("%d", &x[i]);
  }
  solve();
  return 0;
}