#include <bits/stdc++.h>
int main(void) {
  int n;
  char c;
  uint32_t known_value = 0;
  uint32_t value = 0;
  uint32_t flipped = 0;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::cin >> c;
    uint32_t operand;
    std::cin >> operand;
    if (c == '&') {
      known_value |= ~operand;
      value &= operand;
    } else if (c == '|') {
      known_value |= operand;
      value |= operand;
    } else if (c == '^') {
      flipped ^= operand;
      value ^= operand;
    }
  }
  std::cout << "3" << std::endl;
  std::cout << "& " << (~known_value & 1023) << std::endl;
  std::cout << "| " << (known_value & value & 1023) << std::endl;
  std::cout << "^ " << (~known_value & flipped & 1023) << std::endl;
  return 0;
}
