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