#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a = 0, b = 1023, t, ob, zb;
  char c;
  int x = 1023, y = 0, z = 0;
  scanf("%d", &n);
  ;
  for (int i = 0; i < n; ++i) {
    cin >> c >> t;
    if (c == '&') {
      a = a & t;
      b = b & t;
    } else if (c == '|') {
      a = a | t;
      b = b | t;
    } else {
      a = a ^ t;
      b = b ^ t;
    }
  }
  for (int i = 0; i < 10; ++i) {
    zb = (a >> i) & 1;
    ob = (b >> i) & 1;
    if (zb == 0 && ob == 0)
      x -= (1 << i);
    else if (zb == 0 && ob == 1)
      ;
    else if (zb == 1 && ob == 0)
      z += (1 << i);
    else if (zb == 1 && ob == 1)
      y += (1 << i);
  }
  cout << 3 << endl;
  cout << "& " << x << endl;
  cout << "| " << y << endl;
  cout << "^ " << z << endl;
  return 0;
}
