#include <bits/stdc++.h>
int main() {
  int n, i, j, x, s0 = 0, s1 = 1023, ansxor = 0, ansor = 0, ansand = 1023;
  char s[2];
  scanf("%d", &n);
  while (n--) {
    scanf("%s %d", s, &x);
    switch (s[0]) {
      case '|':
        s0 |= x, s1 |= x;
        break;
      case '^':
        s0 ^= x, s1 ^= x;
        break;
      case '&':
        s0 &= x, s1 &= x;
        break;
      default:
        puts(s);
        puts("Error 1");
        return 0;
    };
  }
  for (i = 0; i < 10; ++i) {
    if ((s0 | (1 << (i))) == s0) {
      if ((s1 | (1 << (i))) != s1)
        ansxor += (1 << (i));
      else
        ansor += (1 << (i)), ansand -= (1 << (i));
    } else {
      if ((s1 | (1 << (i))) != s1)
        ansand -= (1 << (i));
      else
        ;
    }
  }
  printf("3\n& %d\n| %d\n^ %d\n", ansand, ansor, ansxor);
  return 0;
}
