#include <bits/stdc++.h>
using namespace std;
const long double pi = 2 * acos(0.0);
const long long prime = 31;
const long long inf = 1e18;
const long long mod = 1e18;
const long long maxn = 5e5 + 11;
long long n, d[2][11], a[maxn], l = 0, r = 1023, cnt;
char o[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> o[i] >> a[i];
  }
  for (int i = 1; i <= n; ++i) {
    if (o[i] == '^') {
      l ^= a[i];
      r ^= a[i];
    } else if (o[i] == '&') {
      l &= a[i];
      r &= a[i];
    } else {
      l |= a[i];
      r |= a[i];
    }
  }
  for (int i = 0; i < 10; ++i) {
    d[0][i] = ((l >> i) & 1);
  }
  for (int i = 0; i < 10; ++i) {
    d[1][i] = (((r >> i) & 1) ^ 1);
  }
  for (int i = 0; i < 10; ++i) {
    if (d[0][i] && d[1][i]) {
      d[0][i] = 0;
      d[1][i] = 0;
      cnt += (1 << i);
    }
  }
  cout << 3 << endl;
  cout << "^ " << cnt << endl;
  cnt = 0;
  for (int i = 0; i < 10; ++i) {
    if (d[0][i]) {
      d[0][i] = 0;
      cnt += (1 << i);
    }
  }
  cout << "| " << cnt << endl;
  cnt = 0;
  for (int i = 0; i < 10; ++i) {
    if (!d[1][i]) {
      d[1][i] = 0;
      cnt += (1 << i);
    }
  }
  cout << "& " << cnt << endl;
  cnt = 0;
  return 0;
}
