#include <bits/stdc++.h>
using namespace std;
int bit(int x, int i) { return (x >> i) & 1; }
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int y = 0;
  int z = 1023;
  int t = 0;
  for (int i = 0; i < (n); i++) {
    string op;
    int a;
    cin >> op >> a;
    for (int i = 0; i < (10); i++) {
      if (bit(a, i)) {
        if (op == "|") {
          t |= 1 << i;
        } else if (op == "&") {
        } else if (op == "^") {
          if (bit(t, i)) {
            t ^= 1 << i;
            z |= 1 << i;
            z ^= 1 << i;
          } else {
            if (bit(z, i)) {
              y ^= 1 << i;
            } else {
              t |= 1 << i;
            }
          }
        }
      } else {
        if (op == "|") {
        } else if (op == "&") {
          t |= 1 << i;
          t ^= 1 << i;
          z |= 1 << i;
          z ^= 1 << i;
        } else if (op == "^") {
        }
      }
    }
  }
  cout << 3 << endl;
  cout << "^ " << y << endl;
  cout << "& " << z << endl;
  cout << "| " << t << endl;
}
