#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int num_and, num_or, num_xor;
  num_and = 0, num_or = 0, num_xor = 0;
  int x = 0, y = 1023;
  char op;
  int op_num;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    getchar();
    scanf("%c%d", &op, &op_num);
    switch (op) {
      case '&':
        x &= op_num, y &= op_num;
        break;
      case '|':
        x |= op_num, y |= op_num;
        break;
      case '^':
        x ^= op_num, y ^= op_num;
        break;
      default:
        break;
    }
  }
  for (int i = 0; i < 10; i++) {
    int bit = 1 << i;
    if (x & bit) {
      if (y & bit) {
        num_and |= bit;
        num_or |= bit;
      } else {
        num_and |= bit;
        num_xor |= bit;
      }
    } else {
      if (y & bit) {
        num_and |= bit;
      }
    }
  }
  printf("3\n");
  printf("& %d\n", num_and);
  printf("| %d\n", num_or);
  printf("^ %d\n", num_xor);
  return 0;
}
