#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
char s[maxn];
int num[maxn];
int one[20], zero[20];
vector<int> ans[5];
int cal(int t, int n) {
  for (int i = 0; i < n; i++) {
    if (s[i] == '|') t |= num[i];
    if (s[i] == '&') t &= num[i];
    if (s[i] == '^') t ^= num[i];
  }
  return t;
}
void Print() {
  int cnt = 0, ans0, ans1, ans3;
  ans0 = ans1 = ans3 = -1;
  for (int i = 0; i < 4; i++)
    if (ans[i].size()) {
      if (i == 2) continue;
      int temp;
      if (i == 0) {
        cnt++;
        temp = 1023;
        for (int j = 0; j < ans[i].size(); j++) {
          temp -= (1 << ans[i][j]);
        }
        ans0 = temp;
      }
      if (i == 1) {
        cnt++;
        temp = 1023;
        for (int j = 0; j < ans[i].size(); j++) {
          temp -= (1 << ans[i][j]);
        }
        temp ^= 1023;
        ans1 = temp;
      }
      if (i == 3) {
        cnt++;
        temp = 0;
        for (int j = 0; j < ans[i].size(); j++) {
          temp += (1 << ans[i][j]);
        }
        ans3 = temp;
      }
    }
  printf("%d\n", cnt);
  if (ans0 != -1) printf("& %d\n", ans0);
  if (ans1 != -1) printf("^ %d\n", ans1);
  if (ans3 != -1) printf("| %d\n", ans3);
}
int main() {
  int n;
  char tt[3];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s%d", tt, &num[i]);
    s[i] = tt[0];
  }
  int t = 1023, p;
  p = cal(t, n);
  for (int i = 0; i < 10; i++) {
    one[i] = p % 2;
    p /= 2;
  }
  t = 0;
  p = cal(t, n);
  for (int i = 0; i < 10; i++) {
    zero[i] = p % 2;
    p /= 2;
  }
  for (int i = 0; i < 10; i++) {
    if (one[i] == 0 && zero[i] == 0) ans[0].push_back(i);
    if (one[i] == 0 && zero[i] == 1) ans[1].push_back(i);
    if (one[i] == 1 && zero[i] == 0) ans[2].push_back(i);
    if (one[i] == 1 && zero[i] == 1) ans[3].push_back(i);
  }
  Print();
  return 0;
}
