#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 2;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, n, ans, andd = 0, orr = 0, xorr = 0;
  char bit[100];
  memset(bit, 'x', sizeof(bit));
  cin >> n;
  for (i = 0; i < n; ++i) {
    char ch;
    long long int first;
    cin >> ch >> first;
    if (ch == '|') {
      for (j = 11; j >= 0; --j) {
        if ((1 << j) & first) bit[j] = '1';
      }
    }
    if (ch == '&') {
      for (j = 11; j >= 0; --j) {
        if ((1 << j) & first) continue;
        bit[j] = '0';
      }
    }
    if (ch == '^') {
      for (j = 11; j >= 0; --j) {
        if ((1 << j) & first) {
          if (bit[j] == 'x')
            bit[j] = 'y';
          else if (bit[j] == 'y')
            bit[j] = 'x';
          else if (bit[j] == '1')
            bit[j] = '0';
          else
            bit[j] = '1';
        }
      }
    }
  }
  for (i = 0; i <= 9; ++i) {
    if (bit[i] == '1') orr += (1 << i);
    if (bit[i] == 'y') xorr += (1 << i);
    if (bit[i] != '0') andd += (1 << i);
  }
  cout << 3 << "\n";
  cout << "| " << orr << "\n";
  cout << "& " << andd << "\n";
  cout << "^ " << xorr << "\n";
}
