#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
char s[maxn];
int a[maxn];
int trans[10][2];
int _xor[10], _or[10], _and[10];
char c;
int main() {
  int n;
  scanf("%d", &n);
  getchar();
  for (int i = 0; i < 10; i++) _and[i] = 1;
  for (int i = 0; i < n; i++) scanf("%c%d%c", &s[i], &a[i], &c);
  for (int i = 0; i < 10; i++) trans[i][0] = 0, trans[i][1] = 1;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < n; k++) {
        if (s[k] == '|')
          trans[j][i] |= ((a[k] >> j) & 1);
        else if (s[k] == '&')
          trans[j][i] &= ((a[k] >> j) & 1);
        else if (s[k] == '^')
          trans[j][i] ^= ((a[k] >> j) & 1);
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    if (trans[i][0] == 1 && trans[i][1] == 1)
      _or[i] = 1;
    else if (trans[i][0] == 0 && trans[i][1] == 0)
      _and[i] = 0;
    else if (trans[i][0] == 1 && trans[i][1] == 0)
      _xor[i] = 1;
  }
  printf("%d\n", 3);
  int num = 0;
  for (int i = 0; i < 10; i++) {
    num += _or[i] ? (1 << i) : 0;
  }
  printf("| %d\n", num);
  num = 0;
  for (int i = 0; i < 10; i++) {
    num += _and[i] ? (1 << i) : 0;
  }
  printf("& %d\n", num);
  num = 0;
  for (int i = 0; i < 10; i++) {
    num += _xor[i] ? (1 << i) : 0;
  }
  printf("^ %d\n", num);
  return 0;
}
