#include <bits/stdc++.h>
int main(void) {
  int n;
  scanf("%d", &n);
  int a = 0, b = 1023;
  for (int i = 1; i <= n; ++i) {
    char ch[2];
    int x;
    scanf("%s%d", ch, &x);
    if (ch[0] == '&') {
      a &= x;
      b &= x;
    } else if (ch[0] == '|') {
      a |= x;
      b |= x;
    } else if (ch[0] == '^') {
      a ^= x;
      b ^= x;
    }
  }
  int ans1 = 0, ans2 = 0;
  for (int T = 0; T < 10; T++) {
    int flag1 = (b & (1 << T));
    int flag2 = (a & (1 << T));
    if (flag1 && flag2) {
      ans1 |= (1 << T);
    } else if (!flag1 && flag2) {
      ans2 ^= (1 << T);
    } else if (!flag1 && !flag2) {
      ans1 |= (1 << T);
      ans2 ^= (1 << T);
    }
  }
  printf("2\n| %d\n^ %d\n", ans1, ans2);
  return 0;
}
