#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a = 0, a1 = 1023, x;
  while (n--) {
    char c;
    cin >> c >> x;
    if (c == '&') a &= x, a1 &= x;
    if (c == '^') a ^= x, a1 ^= x;
    if (c == '|') a |= x, a1 |= x;
  }
  cout << "2\n| " << (a ^ (a1 ^ 1023)) << "\n^ " << (1023 ^ a1) << endl;
  return 0;
}
