#include <bits/stdc++.h>
using namespace std;
int n;
char str[500005][2];
int a[500005];
int ora, xora, anda;
inline int cal(int x) {
  for (int i = 0; i < n; i++) {
    switch (str[i][0]) {
      case '^':
        x ^= a[i];
        break;
      case '&':
        x &= a[i];
        break;
      case '|':
        x |= a[i];
        break;
    }
  }
  return x;
}
inline void init() {
  ora = 0;
  xora = 0;
  anda = 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s%d", str[i], &a[i]);
  }
  int pos = cal(0);
  for (int i = 0; i < 10; i++) {
    int cur = cal((1 << i));
    if ((cur & (1 << i)) == 0 && (pos & (1 << i)) == 0) {
    } else if ((cur & (1 << i)) != 0 && (pos & (1 << i)) != 0) {
      anda += (1 << i);
      ora += (1 << i);
    } else if ((cur & (1 << i)) == 0 && (pos & (1 << i)) != 0) {
      anda += (1 << i);
      xora += (1 << i);
    } else {
      anda += (1 << i);
    }
  }
  printf("3\n");
  printf("& %d\n", anda);
  printf("| %d\n", ora);
  printf("^ %d\n", xora);
  return 0;
}
