#include <bits/stdc++.h>
using namespace std;
struct S {
  int a, b;
  S() {}
  S(int _a, int _b) {
    a = _a;
    b = _b;
  }
  const bool operator<(const S &o) const { return a < o.a; }
};
priority_queue<int, vector<int>, greater<int>> mpq;
const int SPACE = 0, NL = 1;
string exm;
inline void showAll(vector<int> &v, int sep) {
  for (int &here : v) printf("%d%c", here, (sep) ? '\n' : ' ');
}
inline void exf(void) {
  cout << exm << "\n";
  exit(0);
}
inline vector<int> int_seperation(int N, int d = 10) {
  vector<int> v;
  while (N) {
    v.push_back(N % d);
    N /= d;
  }
  reverse(v.begin(), v.end());
  return v;
}
int main() {
  int n;
  scanf("%d", &n);
  int _and = 0, _or = 0, _xor = 0;
  int _0 = 0, _1023 = 1023;
  while (n--) {
    char op;
    int k;
    scanf(" %c %d", &op, &k);
    if (op == '&') {
      _0 &= k;
      _1023 &= k;
    } else if (op == '|') {
      _0 |= k;
      _1023 |= k;
    } else {
      _0 ^= k;
      _1023 ^= k;
    }
  }
  for (int i = 0; i < 10; i++) {
    int b0 = _0 & (1 << i), b1 = _1023 & (1 << i);
    if (b0 && b1) {
      _or += (1 << i);
      _and += (1 << i);
    } else if (!b0 && b1) {
      _and += (1 << i);
    } else if (b0 && !b1) {
      _xor += (1 << i);
      _and += (1 << i);
    }
  }
  printf("3\n");
  printf("& %d\n", _and);
  printf("^ %d\n", _xor);
  printf("| %d\n", _or);
  return 0;
}
