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