#include <bits/stdc++.h>
using namespace std;
char s[2];
int main() {
  int n, s0 = 0, s1 = 0, ss = 1023, s2 = 0;
  scanf("%d", &n);
  for (register int i = 1; i <= n; ++i) {
    int x;
    scanf("%s%d", s, &x);
    if (s[0] == '|')
      s0 &= (ss - x), s1 |= x;
    else if (s[0] == '&')
      x = ss - x, s1 &= (ss - x), s0 |= x;
    else {
      int tmp0 = x & s0, tmp1 = x & s1;
      s0 = s0 - tmp0 + tmp1, s1 = s1 - tmp1 + tmp0;
      s2 ^= x;
    }
  }
  printf("3\n");
  printf("| %d\n", s1);
  s0 = ss - s0;
  printf("& %d\n", s0);
  printf("^ %d\n", s2 & (ss - ((ss - s0) | s1)));
  return 0;
}
