#include <bits/stdc++.h>
using namespace std;
signed main() {
  int n;
  cin >> n;
  int zero = 0, big = 1023;
  for (int i = 0; i < n; i++) {
    char x;
    int ind;
    cin >> x >> ind;
    if (x == '|') {
      zero |= ind;
      big |= ind;
    } else if (x == '&') {
      zero &= ind;
      big &= ind;
    } else {
      zero ^= ind;
      big ^= ind;
    }
  }
  vector<int> Means(10);
  for (int i = 0; i < 10; i++) {
    int zeroLast = zero & 1;
    int bigLast = big & 1;
    if (zeroLast == 0 && bigLast == 0) {
      Means[i] = 0;
    } else if (zeroLast == 1 && bigLast == 0) {
      Means[i] = 1;
    } else if (zeroLast == 1 && bigLast == 1) {
      Means[i] = 3;
    } else
      Means[i] = 2;
    zero = zero >> 1;
    big = big >> 1;
  }
  int maskUmn = 1023;
  int maskXor = 0;
  int maskPlus = 0;
  for (int i = 0; i < 10; i++) {
    if (Means[i] == 0) {
      maskUmn -= (1 << i);
    } else if (Means[i] == 1) {
      maskXor |= (1 << i);
    } else if (Means[i] == 2) {
      maskUmn |= (1 << i);
    } else {
      maskPlus |= (1 << i);
    }
  }
  cout << 3 << endl;
  cout << "& " << maskUmn << endl;
  cout << "| " << maskPlus << endl;
  cout << "^ " << maskXor << endl;
  return 0;
}
