#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 17, z = 10;
bool ch[z];
char t[maxn];
int x[maxn], n;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> t[i] >> x[i];
  for (int k = 0; k < z; k++) {
    int y = 1 << k;
    for (int i = 0; i < n; i++)
      if (t[i] == '|')
        y |= x[i];
      else if (t[i] == '^')
        y ^= x[i];
      else
        y &= x[i];
    ch[k] = y >> k & 1;
  }
  int base = 0;
  for (int i = 0; i < n; i++)
    if (t[i] == '|')
      base |= x[i];
    else if (t[i] == '^')
      base ^= x[i];
    else
      base &= x[i];
  int And = (1 << 10) - 1, Or = 0, Xor = 0;
  for (int i = 0; i < z; i++)
    if (ch[i] == 1 && (base >> i & 1))
      Or |= 1 << i;
    else if (ch[i] == 0 && (base >> i & 1))
      Xor |= 1 << i;
    else if (ch[i] == 0 && !(base >> i & 1))
      And ^= 1 << i;
  cout << 3 << '\n';
  cout << "& " << And << '\n';
  cout << "| " << Or << '\n';
  cout << "^ " << Xor << '\n';
}
