#include <bits/stdc++.h>
using namespace std;
const int maxN = 5e4;
int mask[10];
void applyOr(int key) {
  for (int i = 0; i < 10; i++) {
    if (mask[i] < 2) {
      mask[i] |= ((1 << i) & key) ? 1 : 0;
    } else {
      if ((1 << i) & key) mask[i] = 1;
    }
  }
}
void applyAnd(int key) {
  for (int i = 0; i < 10; i++) {
    if (mask[i] < 2) {
      mask[i] &= ((1 << i) & key) ? 1 : 0;
    } else {
      if (((1 << i) & key) == 0) mask[i] = 0;
    }
  }
}
void applyXor(int key) {
  for (int i = 0; i < 10; i++) {
    mask[i] ^= ((1 << i) & key) ? 1 : 0;
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  for (int i = 0; i < 10; i++) {
    mask[i] = 2;
  }
  int n;
  char c;
  cin >> n;
  for (int i = 0, tmp; i < n; i++) {
    cin >> c >> tmp;
    switch (c) {
      case '|':
        applyOr(tmp);
        break;
      case '&':
        applyAnd(tmp);
        break;
      default:
        applyXor(tmp);
    }
  }
  int xorKey = 0, orKey = 0, andKey = 1023;
  for (int i = 0; i < 10; i++) {
    if (mask[i] == 3)
      xorKey |= 1 << i;
    else if (mask[i] == 1)
      orKey |= 1 << i;
    else if (mask[i] == 0)
      andKey ^= 1 << i;
  }
  cout << "3\n^ " << xorKey << "\n& " << andKey << "\n| " << orKey << '\n';
}
