#include <bits/stdc++.h>
using namespace std;
const int mpow = 10;
int main() {
  int n;
  scanf("%i", &n);
  int one[mpow];
  int zero[mpow];
  for (int i = 0; i < mpow; i++) one[i] = 1;
  for (int i = 0; i < mpow; i++) zero[i] = 0;
  for (int i = 0; i < n; i++) {
    char c;
    int x;
    scanf(" %c %i", &c, &x);
    for (int j = 0; j < mpow; j++) {
      int tmp = 0;
      if (x & (1 << j)) tmp = 1;
      if (c == '|') {
        one[j] |= tmp;
        zero[j] |= tmp;
      } else if (c == '^') {
        one[j] ^= tmp;
        zero[j] ^= tmp;
      } else {
        one[j] &= tmp;
        zero[j] &= tmp;
      }
    }
  }
  int or_val = 0;
  int and_val = 0;
  int xor_val = 0;
  for (int i = 0; i < mpow; i++) {
    if (one[i] == 1 and zero[i] == 0) {
      and_val += 1 << i;
    } else if (one[i] == 1 and zero[i] == 1) {
      and_val += 1 << i;
      or_val += 1 << i;
    } else if (one[i] == 0 and zero[i] == 1) {
      and_val += 1 << i;
      xor_val += 1 << i;
    } else if (one[i] == 0 and zero[i] == 0) {
    }
  }
  printf("3 \n");
  printf("| %i\n", or_val);
  printf("& %i\n", and_val);
  printf("^ %i\n", xor_val);
  for (int i = 0; i < mpow; i++) {
    int tmp1 = 1;
    int tmp2 = 0;
    int tmp = 0;
    if (or_val & (1 << i)) tmp = 1;
    tmp1 |= tmp;
    tmp2 |= tmp;
    tmp = 0;
    if (and_val & (1 << i)) tmp = 1;
    tmp1 &= tmp;
    tmp2 &= tmp;
    tmp = 0;
    if (xor_val & (1 << i)) tmp = 1;
    tmp1 ^= tmp;
    tmp2 ^= tmp;
  }
  return 0;
}
