#include <bits/stdc++.h>
using std::vector;
size_t operation(size_t x, size_t y, char c) {
  if (c == '|') {
    return x | y;
  }
  if (c == '^') {
    return x ^ y;
  }
  if (c == '&') {
    return x & y;
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  size_t n;
  std::cin >> n;
  vector<size_t> bits0(10, 0), bits1(10, 1);
  for (size_t i = 0; i < n; ++i) {
    char x;
    size_t y;
    std::cin >> x >> y;
    for (size_t j = 0; j < 10; ++j) {
      size_t z = !!(y & 1 << j);
      bits0[j] = operation(bits0[j], z, x);
      bits1[j] = operation(bits1[j], z, x);
    }
  }
  size_t cnt_or = 0, cnt_xor = 0, cnt_and = (1 << 10) - 1;
  for (size_t i = 0; i < 10; ++i) {
    size_t x = 1 << i;
    if (bits0[i] == 1 && bits1[i] == 1) cnt_or |= x;
    if (bits0[i] == 0 && bits1[i] == 0) cnt_and &= ~x;
    if (bits0[i] == 1 && bits1[i] == 0) cnt_xor |= x;
  }
  std::cout << 3 << '\n'
            << "| " << cnt_or << '\n'
            << "^ " << cnt_xor << '\n'
            << "& " << cnt_and;
  return 0;
}
