#include <bits/stdc++.h>
int main() {
  unsigned int a = 1023, b = 0;
  int n;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    char c;
    int x;
    std::cin >> c >> x;
    switch (c) {
      case '|':
        a |= x;
        b |= x;
        break;
      case '&':
        a &= x;
        b &= x;
        break;
      case '^':
        a ^= x;
        b ^= x;
        break;
      default:
        break;
    }
  }
  std::cout << "3\n";
  std::cout << "& " << (a | b) % 1024 << '\n';
  std::cout << "| " << (a & b) % 1024 << '\n';
  std::cout << "^ " << (~a & b) % 1024 << '\n';
}
