#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int And = 1023, Or = 0, Xor = 0;
  int num;
  char command;
  int state[10];
  for (int i = 0; i < 10; i++) state[i] = 2;
  for (int i = 0; i < n; i++) {
    cin >> command;
    scanf("%d", &num);
    if (command == '|') {
      for (int i = 0; i < 10; i++) {
        if (num & (1 << i)) state[i] = 1;
      }
    } else if (command == '&') {
      for (int i = 0; i < 10; i++) {
        if (!(num & (1 << i))) state[i] = 0;
      }
    } else {
      for (int i = 0; i < 10; i++) {
        if (num & (1 << i)) state[i] ^= 1;
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    if (state[i] == 1) Or += (1 << i);
    if (state[i] == 0) And -= (1 << i);
    if (state[i] == 3) Xor += (1 << i);
  }
  printf("%d\n", 3);
  printf("| %d\n", Or);
  printf("^ %d\n", Xor);
  printf("& %d\n", And);
  return 0;
}
