#include <bits/stdc++.h>
using namespace std;
int a[15][2], N, op[15], ans[15];
char s[5];
int main() {
  scanf("%d", &N);
  for (int i = 0; i <= 9; i++) a[i][1] = 1;
  while (N--) {
    int v;
    scanf("%s%d", s, &v);
    for (int i = 0; i <= 9; i++)
      for (int j = 0; j <= 1; j++) {
        int o = ((v >> i) & 1);
        if (s[0] == '|') a[i][j] |= o;
        if (s[0] == '&') a[i][j] &= o;
        if (s[0] == '^') a[i][j] ^= o;
      }
  }
  for (int i = 0; i <= 9; i++) {
    if (a[i][0] == 0 && a[i][1] == 0) {
      op[i] = 3;
    }
    if (a[i][0] == 1 && a[i][1] == 0) {
      op[i] = 1;
    }
    if (a[i][0] == 1 && a[i][1] == 1) {
      op[i] = 2;
    }
  }
  ans[1] = 0;
  ans[2] = 0;
  ans[3] = (1 << (10)) - 1;
  for (int i = 0; i <= 9; i++) {
    ans[op[i]] ^= (1 << (i));
  }
  puts("3");
  printf("^ %d\n", ans[1]);
  printf("| %d\n", ans[2]);
  printf("& %d\n", ans[3]);
  return 0;
}
