#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  unsigned long long a = 0, b = (1 << 10) - 1;
  unsigned long long a1 = a, b1 = b;
  for (int i = 0; i < n; ++i) {
    char s;
    int x;
    cin >> s;
    if (s == '&') {
      cin >> x;
      a &= x, b &= x;
    } else if (s == '^') {
      cin >> x;
      a ^= x, b ^= x;
    } else {
      cin >> x;
      a |= x, b |= x;
    }
  }
  for (int x = 0; x < 1024; ++x) {
    for (int y = 0; y < 1024; ++y) {
      for (int z = 0; z < 1024; ++z) {
        if ((a1 & x ^ y | z) == a && (b1 & x ^ y | z) == b) {
          cout << 3 << '\n';
          cout << "& " << x << '\n';
          cout << "^ " << y << '\n';
          cout << "| " << z << '\n';
          return 0;
        }
      }
    }
  }
  return 0;
}
