#include <bits/stdc++.h>
using namespace std;
const unsigned long long int N = 2e3 + 5;
const unsigned long long int mod = 2e9 + 33;
const unsigned long long int STEP = 1e6;
int main() {
  ios::sync_with_stdio(false);
  unsigned long long int x = 0, y = 1023;
  unsigned long long int n;
  cin >> n;
  for (unsigned long long int i = 0; i < n; i++) {
    char type;
    unsigned long long int val;
    cin >> type >> val;
    if (type == '&') {
      x &= val;
      y &= val;
    }
    if (type == '|') {
      x |= val;
      y |= val;
    }
    if (type == '^') {
      x ^= val;
      y ^= val;
    }
  }
  unsigned long long int xor_num = ~(y);
  unsigned long long int or_num = ~(x ^ y);
  xor_num &= 1023;
  or_num &= 1023;
  cout << "2 | " << or_num << "\n^ " << xor_num << endl;
  return 0;
}
