#include <bits/stdc++.h>
using namespace std;
int getbit(int x, int y) { return (x >> (y - 1)) & 1; }
char c;
int n, x, a[20], _and, _xor, _or, k;
int main() {
  scanf("%d\n", &n);
  for (int i = 1; i <= 10; i++) a[i] = 2;
  for (int i = 1; i <= n; i++) {
    scanf("%c %d\n", &c, &x);
    for (int j = 1; j <= 10; j++) {
      k = getbit(x, j);
      if (c == '|' && k == 1) a[j] = 1;
      if (c == '&' && k == 0) a[j] = 0;
      if (c == '^' && k == 1) {
        if (a[j] == 1)
          a[j] = 0;
        else if (a[j] == 0)
          a[j] = 1;
        else
          a[j] = -a[j];
      }
    }
  }
  _and = 1023;
  for (int i = 1; i <= 10; i++) {
    if (a[i] == -2) _xor = _xor ^ (1 << (i - 1));
    if (a[i] == 0) _and = _and ^ (1 << (i - 1));
    if (a[i] == 1) _or = _or ^ (1 << (i - 1));
  }
  printf("3\n");
  printf("& %d\n", _and);
  printf("| %d\n", _or);
  printf("^ %d\n", _xor);
  return 0;
}
