#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, x;
  char c;
  long long temp1 = 0;
  long long temp2 = 1023;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> c >> x;
    if (c == '|') {
      temp1 |= x;
      temp2 |= x;
    } else if (c == '&') {
      temp1 &= x;
      temp2 &= x;
    } else {
      temp1 ^= x;
      temp2 ^= x;
    }
  }
  long long ans = 1023;
  long long ans2 = 0;
  long long ans3 = 0;
  for (long long i = 0; i < 10; i++)
    if ((temp1 & (1LL << i)) == 0 && (temp2 & (1LL << i)) == 0)
      ans ^= (1LL << i);
  for (long long i = 0; i < 10; i++)
    if ((temp1 & (1LL << i)) && (temp2 & (1LL << i))) ans2 ^= (1LL << i);
  for (long long i = 0; i < 10; i++)
    if ((temp1 & (1LL << i)) && (temp2 & (1LL << i)) == 0) ans3 ^= (1LL << i);
  cout << 3 << "\n"
       << "& " << ans << "\n"
       << "| " << ans2 << "\n"
       << "^ " << ans3;
  return 0;
}
