#include <bits/stdc++.h>
using namespace std;
int N;
long long int K;
int Ar[5005];
int main() {
  cin >> N;
  int zero = 0, top = 1023, x;
  char c;
  for (int i = 1; i <= N; i++) {
    cin >> c >> x;
    if (c == '|') {
      zero = zero | x;
      top = top | x;
    }
    if (c == '^') {
      zero = zero ^ x;
      top = top ^ x;
    }
    if (c == '&') {
      zero = zero & x;
      top = top & x;
    }
  }
  int xorans = 0, orans = 0;
  for (int i = 0; i <= 9; i++) {
    int zerobit = zero & (1 << i);
    int topbit = top & (1 << i);
    if (zerobit == 0 && topbit == 0) {
      orans = orans | (1 << i);
      xorans = xorans | (1 << i);
    }
    if (zerobit == 0 && topbit) {
    }
    if (zerobit && topbit == 0) {
      xorans = xorans | (1 << i);
    }
    if (zerobit && topbit) {
      orans = orans | (1 << i);
    }
  }
  cout << 2 << endl;
  cout << "| " << orans << endl;
  cout << "^ " << xorans << endl;
  return 0;
}
