#include <bits/stdc++.h>
using namespace std;
int a, a2 = 1023;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    char x;
    int y;
    cin >> x >> y;
    if (x == '^')
      a ^= y, a2 ^= y;
    else if (x == '|')
      a |= y, a2 |= y;
    else
      a &= y, a2 &= y;
  }
  puts("2");
  cout << '|' << ' ' << (a ^ (a2 ^ 1023)) << endl;
  cout << '^' << ' ' << (a2 ^ 1023) << endl;
}
