#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int main() {
  char str[5];
  int n, num;
  scanf("%d", &n);
  int a = 1023, b = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%s%d", str, &num);
    if (str[0] == '|') {
      a |= num;
      b |= num;
    }
    if (str[0] == '&') {
      a &= num;
      b &= num;
    }
    if (str[0] == '^') {
      a ^= num;
      b ^= num;
    }
  }
  int numor = 0, numand = 0, numxor = 0;
  for (int i = 0; i < 10; i++) {
    int x = (1 << i);
    if ((a & x) && (b & x)) numor += x;
    if (!(a & x) && (b & x)) numxor += x;
    if (!(a & x) && !(b & x)) numor += x, numxor += x;
  }
  int sum = 0;
  int ans = (numor > 0) + (numand > 0) + (numxor > 0);
  printf("%d\n", ans);
  if (numor) {
    printf("| %d\n", numor);
  }
  if (numand) {
    printf("& %d\n", numand);
  }
  if (numxor) {
    printf("^ %d\n", numxor);
  }
  return 0;
}
