#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, j, num, curr;
  char c;
  std::vector<pair<char, int> > v;
  vector<int> ans;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> c >> num;
    v.push_back({c, num});
  }
  for (i = 0; i < 10; i++) {
    curr = 2;
    for (j = 0; j < n; j++) {
      num = v[j].second;
      c = v[j].first;
      if (c == '|' && (num & (1 << i))) curr = 1;
      if (c == '&' && (num & (1 << i)) == 0) curr = 0;
      if (c == '^' && (num & (1 << i))) {
        if (curr == 2)
          curr = -2;
        else if (curr == -2)
          curr = 2;
        else if (curr == 1)
          curr = 0;
        else if (curr == 0)
          curr = 1;
      }
    }
    ans.push_back(curr);
  }
  int p = 1;
  int xxor = 0, aand = 0, oor = 0;
  for (i = 0; i < 10; i++) {
    if (ans[i] == -2) xxor += p;
    if (ans[i] != 0) aand += p;
    if (ans[i] == 1) oor += p;
    p *= 2;
  }
  cout << "3\n";
  cout << "^ " << xxor << endl;
  cout << "& " << aand << endl;
  cout << "| " << oor << endl;
  return 0;
}
