#include <bits/stdc++.h>
int n, f[20];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 10; ++i) {
    f[i] = -1;
  }
  char s[3];
  for (int i = 1, a; i <= n; ++i) {
    scanf("%s%d", s, &a);
    if (s[0] == '|') {
      for (int i = 0, j = 1; j <= a; ++i, j <<= 1) {
        if (a & j) {
          f[i] = 1;
        }
      }
    } else if (s[0] == '&') {
      for (int i = 0, j = 1; i < 10; ++i, j <<= 1) {
        if (!(a & j)) {
          f[i] = 0;
        }
      }
    } else if (s[0] == '^') {
      for (int i = 0, j = 1; i < 10; ++i, j <<= 1) {
        if (j & a) {
          f[i] = 1 - f[i];
        }
      }
    }
  }
  int a[5] = {0};
  for (int i = 0; i < 10; ++i) {
    a[f[i] + 1] |= 1 << i;
  }
  printf("3\n");
  printf("& %d\n| %d\n^ %d\n", 1023 - a[1], a[2], a[3]);
}
