#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a = 1023, b = 0, val;
  scanf("%d\n", &n);
  char op;
  for (int i = 0; i < n; i++) {
    scanf("%c %d\n", &op, &val);
    if (op == '&') {
      a &= val;
      b &= val;
    } else if (op == '|') {
      a |= val;
      b |= val;
    } else {
      a ^= val;
      b ^= val;
    }
  }
  int aand, oor, xxor;
  oor = xxor = 0;
  aand = 1023;
  for (int i = 0; i < 10; i++) {
    bool res1 = (a & (1 << i)) != 0;
    bool res2 = (b & (1 << i)) != 0;
    if (res1 == 1 && res2 == 0) {
      continue;
    } else if (res1 == 1 && res2 == 1) {
      oor |= (1 << i);
    } else if (res1 == 0 && res2 == 0) {
      aand ^= (1 << i);
    } else {
      xxor |= (1 << i);
    }
  }
  cout << '3' << endl;
  cout << '&' << " " << aand << endl;
  cout << '|' << " " << oor << endl;
  cout << '^' << " " << xxor << endl;
  return 0;
}
