#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 1e6 + 8;
int N, M, K, Q;
char op[MAXN];
int x[MAXN];
int ans[3];
void preprocess() {}
void solution() {
  int zeros = 0, ones = 1023;
  for (int i = 0; i < N; ++i) {
    switch (op[i]) {
      case '|':
        zeros |= x[i], ones |= x[i];
        break;
      case '&':
        zeros &= x[i], ones &= x[i];
        break;
      case '^':
        zeros ^= x[i], ones ^= x[i];
        break;
    }
  }
  ans[0] = 1023;
  for (int i = 0; i < 10; ++i) {
    int o = 1 << i & ones, z = 1 << i & zeros;
    if (!o && !z) ans[0] ^= 1 << i;
    if (o && z) ans[1] |= 1 << i;
    if (!o && z) ans[2] |= 1 << i;
  }
}
int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> op[i] >> x[i];
  solution();
  cout << "3\n";
  cout << "& " << ans[0] << '\n';
  cout << "| " << ans[1] << '\n';
  cout << "^ " << ans[2] << '\n';
  return 0;
}
