#include <bits/stdc++.h>
using namespace std;
const int maxn = 20;
int n, c;
char ch[2];
int num[maxn];
int main() {
  ios::sync_with_stdio(false);
  while (scanf("%d", &n) != EOF) {
    memset(num, 0, sizeof(num));
    for (int i = 0; i < n; ++i) {
      scanf("%s%d", ch, &c);
      for (int j = 0; j < 10; ++j) {
        int tmp = ((c >> j) & 1);
        if (ch[0] == '&') {
          if (tmp == 0) {
            num[j] = 3;
          }
        } else if (ch[0] == '|') {
          if (tmp == 1) {
            num[j] = 2;
          }
        } else if (ch[0] == '^') {
          if (tmp == 1) {
            num[j] ^= 1;
          }
        }
      }
    }
    int Xor = 0, Or = 0, And = 1023;
    for (int i = 0; i < 10; ++i) {
      if (num[i] == 1) {
        Xor |= (1 << i);
      } else if (num[i] == 2) {
        Or |= (1 << i);
      } else if (num[i] == 3) {
        And ^= (1 << i);
      }
    }
    printf("3\n");
    printf("| %d\n", Or);
    printf("^ %d\n", Xor);
    printf("& %d\n", And);
  }
  return 0;
}
