#include <bits/stdc++.h>
using namespace std;
int flag[1234];
void f(char C, int t) {
  int cnt = 0;
  while (t > 1) {
    if (t & 1) {
      if (C == '|') {
        flag[cnt] = 1;
      } else if (C == '^') {
        if (flag[cnt] == 1)
          flag[cnt] = -1;
        else if (flag[cnt] == -1)
          flag[cnt] = 1;
        else if (flag[cnt] == 2)
          flag[cnt] = 0;
        else
          flag[cnt] = 2;
      }
    } else {
      if (C == '&') flag[cnt] = -1;
    }
    t >>= 1;
    cnt++;
  }
}
int main() {
  int n, t;
  char C;
  scanf("%d ", &n);
  for (int i = 0; i < n; i++) {
    scanf("%c %d ", &C, &t);
    f(C, t + 1024);
  }
  int a = 1023, b = 0, c = 0;
  for (int i = 0; i < 15; i++) {
    if (flag[i] == -1) {
      a -= pow(2, i);
    } else if (flag[i] == 1) {
      b += pow(2, i);
    } else if (flag[i] == 2) {
      c += pow(2, i);
    }
  }
  cout << 3 << endl;
  cout << '&' << ' ' << a << '\n';
  cout << '|' << ' ' << b << '\n';
  cout << '^' << ' ' << c << '\n';
}
