#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x0 = 0, x1 = 1023;
  while (n--) {
    char op;
    int a;
    cin >> op >> a;
    if (op == '&') {
      x0 &= a;
      x1 &= a;
    } else if (op == '^') {
      x0 ^= a;
      x1 ^= a;
    } else {
      x0 |= a;
      x1 |= a;
    }
  }
  int ornum = 0, xornum = 0;
  for (int x = 1; x < 1024; x <<= 1) {
    int y1 = x1 & x;
    int y0 = x0 & x;
    if (y0 == y1) ornum |= x;
    if (y1 == 0) xornum |= x;
  }
  cout << 2 << endl;
  cout << "| " << ornum << endl;
  cout << "^ " << xornum << endl;
  return 0;
}
