#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int n, a[N];
char c[N];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> c[i] >> a[i];
  }
  int x, y, z;
  z = 1023, x = y = 0;
  for (int i = 0; i < 10; ++i) {
    int pos = -1;
    bool t = 0;
    for (int j = 0; j < n; ++j) {
      if (c[j] == '|' && a[j] >> i & 1) pos = j, t = 1;
      if (c[j] == '&' && !(a[j] >> i & 1)) pos = j, t = 0;
    }
    for (int j = pos + 1; j < n; ++j) {
      if (c[j] == '^') t ^= (a[j] >> i & 1);
    }
    if (pos == -1)
      x |= t * 1 << i;
    else {
      if (t)
        y |= 1 << i;
      else
        z ^= 1 << i;
    }
  }
  cout << "3\n";
  cout << "^ " << x << '\n';
  cout << "| " << y << '\n';
  cout << "& " << z << '\n';
}
