#include <bits/stdc++.h>
using namespace std;
const long long int INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
int n, d;
char ch;
int ans[10];
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  scanf("%d", &n);
  for (int i = 0; i < 10; i++) ans[i] = 2;
  for (int i = 0; i < n; i++) {
    scanf(" %c %d", &ch, &d);
    bitset<10> temp(d);
    if (ch == '&') {
      for (int i = 0; i < 10; i++) {
        if (temp[i] == 0) ans[i] = 0;
      }
    } else if (ch == '|') {
      for (int i = 0; i < 10; i++) {
        if (temp[i] == 1) ans[i] = 1;
      }
    } else {
      for (int i = 0; i < 10; i++) {
        if (temp[i] == 1) {
          if (ans[i] == 2)
            ans[i] = -1;
          else if (ans[i] == -1)
            ans[i] = 2;
          else
            ans[i] = 1 - ans[i];
        }
      }
    }
  }
  printf("3\n");
  int s = 1023;
  for (int i = 0; i < 10; i++) {
    if (ans[i] == 0) s = s - (1 << i);
  }
  printf("& %d\n", s);
  s = 0;
  for (int i = 0; i < 10; i++) {
    if (ans[i] == 1) s += (1 << i);
  }
  printf("| %d\n", s);
  s = 0;
  for (int i = 0; i < 10; i++) {
    if (ans[i] == -1) s += (1 << i);
  }
  printf("^ %d", s);
  return 0;
}
