#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int a = 0, b = (1 << 10) - 1;
  while (n--) {
    string s;
    int x;
    cin >> s >> x;
    if (s == "|")
      a |= x, b |= x;
    else if (s == "^")
      a ^= x, b ^= x;
    else
      a &= x, b &= x;
  }
  int x = 0, y = 0, z = 0;
  for (int i = 0; i < 10; i++) {
    int p = (a >> i & 1), q = (b >> i & 1);
    if (p and q)
      x |= 1 << i, y |= 1 << i;
    else if (p and !q)
      z |= 1 << i, y |= 1 << i;
    else if (!p and q)
      y |= 1 << i;
  }
  cout << 3 << '\n';
  cout << "| " << x << '\n';
  cout << "& " << y << '\n';
  cout << "^ " << z << '\n';
  return 0;
}
