#include <bits/stdc++.h>
using namespace std;
long long op(long long x, pair<char, long long> o) {
  if (o.first == '|') return (x | o.second);
  if (o.first == '&') return (x & o.second);
  return (x ^ o.second);
}
signed main() {
  long long n;
  cin >> n;
  vector<pair<char, long long>> v(n);
  for (long long i = 0; i < n; ++i) cin >> v[i].first >> v[i].second;
  vector<long long> v0(11, 0), v1(11, 1);
  for (long long i = 0; i < n; ++i)
    for (long long j = 0; j < 11; ++j) {
      v0[j] = (op(v0[j] << j, v[i]) >> j) & 1;
      v1[j] = (op(v1[j] << j, v[i]) >> j) & 1;
    }
  long long or_number = 0;
  long long xor_number = 0;
  for (long long j = 9; j >= 0; --j) {
    xor_number <<= 1;
    or_number <<= 1;
    or_number += (v0[j] == v1[j]);
    xor_number += (v1[j] == 0);
  }
  cout << (2 + (v1[10] == 0)) << '\n';
  cout << "| " << or_number << '\n';
  cout << "^ " << xor_number << '\n';
  if (v1[10] == 0) cout << "& 1023" << '\n';
}
