#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
bool arr[11][2];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 10; i++) arr[i][1] = 1;
  while (n--) {
    char c;
    int x;
    scanf(" %c%d", &c, &x);
    if (c == '^') {
      for (int i = 0; i < 10; i++)
        if (x >> i & 1)
          for (int j = 0; j < 2; j++) arr[i][j] ^= 1;
    }
    if (c == '|') {
      for (int i = 0; i < 10; i++)
        if (x >> i & 1)
          for (int j = 0; j < 2; j++) arr[i][j] |= 1;
    }
    if (c == '&') {
      for (int i = 0; i < 10; i++) {
        int bit = x >> i & 1;
        for (int j = 0; j < 2; j++) arr[i][j] &= bit;
      }
    }
  }
  int a = 0, b = 0, c = 0;
  for (int i = 0; i < 10; i++) {
    if (arr[i][0] and !arr[i][1]) a += (1 << i);
    if (arr[i][0] and arr[i][1]) b += (1 << i);
    if (arr[i][0] or arr[i][1]) c += (1 << i);
  }
  puts("3");
  ;
  printf("^ %d\n", a);
  printf("| %d\n", b);
  printf("& %d\n", c);
  return 0;
}
