#include <bits/stdc++.h>
using namespace std;
const int MAX = 500005;
int v[MAX];
char c[MAX];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> c[i] >> v[i];
  int a = 0, o = 0, x = 0;
  for (int b = 0; b < 10; b++) {
    int r0 = 0, r1 = 1;
    for (int i = 0; i < n; i++) {
      int val = ((v[i] >> b) & 1);
      if (c[i] == '&') r0 &= val;
      if (c[i] == '|') r0 |= val;
      if (c[i] == '^') r0 ^= val;
    }
    for (int i = 0; i < n; i++) {
      int val = ((v[i] >> b) & 1);
      if (c[i] == '&') r1 &= val;
      if (c[i] == '|') r1 |= val;
      if (c[i] == '^') r1 ^= val;
    }
    if (r0 == r1) {
      if (r0 == 0)
        continue;
      else
        o |= (1 << b);
    } else {
      a |= (1 << b);
      if (r0 == 0)
        continue;
      else
        x |= (1 << b);
    }
  }
  cout << "3\n^ " << x << "\n& " << a << "\n| " << o << "\n";
  return 0;
}
