#include <bits/stdc++.h>
using namespace std;
int n, f[11], t[11];
char x;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> x >> a;
    for (int j = 0; j < 10; j++) {
      if (x == '&' && (a & (1 << j)) == 0) f[j] = -1;
      if (x == '|' && (a & (1 << j))) f[j] = 1;
      if (x == '^' && (a & (1 << j))) f[j] *= -1, t[j] ^= 1;
    }
  }
  int a = 0, b = 1023, c = 0;
  for (int i = 0; i < 10; i++) {
    if (f[i] == 1) a += (1 << i);
    if (f[i] == -1) b -= (1 << i);
    if (f[i] == 0 && t[i]) c += (1 << i);
  }
  cout << "3" << endl
       << "| " << a << endl
       << "& " << b << endl
       << "^ " << c << endl;
  return 0;
}
