#include <bits/stdc++.h>
using namespace std;
using ii = tuple<long long, long long>;
const long long N = 1e6 + 7, inf = 1e9 + 42;
long long binpow(long long a, long long b) {
  if (b == 0) return 1;
  long long res = binpow(a, b / 2);
  if (b % 2)
    return (res * res * a) % 1000000007;
  else
    return (res * res) % 1000000007;
}
bool compare(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first == b.first)
    return (a.second > b.second);
  else
    return (a.first <= b.first);
}
char op[(long long)1e6];
long long A[(long long)1e6];
signed main() {
  long long n;
  cin >> n;
  ;
  long long P = 0, S = 0;
  for (long long i = 1; i < n + 1; i++) {
    cin >> op[i] >> A[i];
    if (op[i] == '|') {
      P |= A[i];
      S |= A[i];
    }
    if (op[i] == '&') {
      P &= A[i];
      S |= (1023 - A[i]);
    }
    if (op[i] == '^') P ^= A[i];
  }
  cout << "2" << endl;
  cout << "| " << S << endl;
  cout << "^ " << (P ^ S) << endl;
}
