#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int bitPos[10][2];
  int action[n], var[n];
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c >> var[i];
    action[i] = c;
  }
  for (int i = 0; i < 10; i++) {
    for (int bit = 0; bit < 2; bit++) {
      int v = (bit) << i;
      for (int k = 0; k < n; k++) {
        if (action[k] == '^') {
          v = v ^ (var[k] & (1 << i));
        } else if (action[k] == '|') {
          v = v | (var[k] & (1 << i));
        } else {
          v = v & (var[k] & (1 << i));
        }
      }
      bitPos[i][bit] = v >> i;
    }
  }
  int AND = (1 << 10) - 1, OR = 0, XOR = 0;
  for (int i = 0; i < 10; i++) {
    if (bitPos[i][0] == 0 && bitPos[i][1] == 0) AND = AND & (~(1 << i));
    if (bitPos[i][0] == 1 && bitPos[i][1] == 1) OR = OR | ((1 << i));
    if (bitPos[i][0] == 1 && bitPos[i][1] == 0) XOR = XOR | ((1 << i));
  }
  cout << 3 << endl << "& " << AND << endl << "| " << OR << endl << "^ " << XOR;
  return 0;
}
