#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  short x[10];
  for (int i = 0; i < 10; i++) x[i] = 2;
  for (int i = 0; i < n; i++) {
    char op;
    int a;
    cin >> op >> a;
    bitset<10> b(a);
    if (op == '&') {
      for (int j = 0; j < 10; j++) {
        if (b[9 - j] == 0) x[j] = 0;
      }
    } else if (op == '|') {
      for (int j = 0; j < 10; j++) {
        if (b[9 - j] == 1) x[j] = 1;
      }
    } else {
      for (int j = 0; j < 10; j++) {
        if (b[9 - j] == 1) {
          switch (x[j]) {
            case 0:
              x[j] = 1;
              break;
            case 1:
              x[j] = 0;
              break;
            case 2:
              x[j] = 3;
              break;
            case 3:
              x[j] = 2;
              break;
            default:
              break;
          }
        }
      }
    }
  }
  int andd = 0, orr = 0, xorr = 0;
  for (int i = 0; i < 10; i++) {
    if (x[i] != 0) andd += pow(2, 9 - i);
  }
  for (int i = 0; i < 10; i++) {
    if (x[i] == 1) orr += pow(2, 9 - i);
  }
  for (int i = 0; i < 10; i++) {
    if (x[i] == 3) xorr += pow(2, 9 - i);
  }
  cout << 3 << endl;
  cout << "& " << andd << endl << "| " << orr << endl << "^ " << xorr;
  return 0;
}
