#include <bits/stdc++.h>
using namespace std;
using INT = long long;
using pci = pair<char, int>;
const int N = 1023;
pci p[500100];
char s[] = {
    '&',
    '|',
    '^',
};
int ans[20][2];
int val[500100];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    char c;
    int first;
    scanf(" %c %d", &c, &first);
    p[i] = pci(c, first);
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 2; j++) {
      ans[i][j] = j;
      for (int k = 1; k <= n; k++) {
        int tmp = p[k].second;
        int op = (tmp & (1 << i));
        if (op) op = 1;
        if (p[k].first == s[0]) ans[i][j] = (ans[i][j] & op);
        if (p[k].first == s[1]) ans[i][j] = (ans[i][j] | op);
        if (p[k].first == s[2]) ans[i][j] ^= op;
      }
    }
  }
  int first = 0, second = 0;
  for (int i = 0; i < 10; i++) {
    if (ans[i][0] == ans[i][1]) {
      first += (1 << i);
      second += (ans[i][0] ^ 1) * (1 << i);
    } else {
      second += (ans[i][0] ^ 0) * (1 << i);
    }
  }
  cout << 2 << endl;
  cout << s[1] << " " << first << endl;
  cout << s[2] << " " << second << endl;
  return 0;
}
