#include <bits/stdc++.h>
using namespace std;
int n;
int a = 0;
int b = 1023;
int main(void) {
  cin >> n;
  for (int i = 0; i < n; i++) {
    char c;
    int x;
    cin >> c >> x;
    switch (c) {
      case '|':
        a |= x;
        b |= x;
        break;
      case '&':
        a &= x;
        b &= x;
        break;
      case '^':
        a ^= x;
        b ^= x;
        break;
    }
  }
  cout << "2\n";
  cout << "| " << (a ^ (b ^ 1023)) << "\n";
  cout << "^ " << (b ^ 1023) << "\n";
  return 0;
}
