#include <bits/stdc++.h>
using namespace std;
char c;
int x;
int cnt[15];
int OK[15];
int main() {
  int n;
  scanf("%d", &n);
  memset(OK, -1, sizeof OK);
  for (int j = 0; j < n; j++) {
    getchar();
    scanf("%c %d", &c, &x);
    if (c == '&') {
      for (int i = 0; i < 12; i++) {
        if ((x & (1 << i)) == 0) OK[i] = 0;
      }
    }
    if (c == '|') {
      for (int i = 0; i < 12; i++) {
        if ((x & (1 << i)) > 0) OK[i] = 1;
      }
    }
    if (c == '^') {
      for (int i = 0; i < 12; i++) {
        if ((x & (1 << i)) > 0) {
          if (OK[i] != -1) {
            OK[i] = OK[i] ^ 1;
          } else {
            cnt[i]++;
          }
        }
      }
    }
  }
  int And = 1023, Or = 0, Xor = 0;
  for (int i = 0; i < 10; i++) {
    if (OK[i] == 0) {
      And = (And ^ (1 << (i)));
    } else if (OK[i] == 1) {
      Or = (Or | (1 << (i)));
    } else {
      if (cnt[i] % 2 == 1) Xor = (Xor | (1 << (i)));
    }
  }
  printf("3\n");
  printf("& %d\n", And);
  printf("| %d\n", Or);
  printf("^ %d\n", Xor);
}
