#include <bits/stdc++.h>
int main() {
  int a = 0x3FF, b = 0x000, c = 0x000;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    char op;
    scanf(" %c", &op);
    int x;
    scanf("%d", &x);
    switch (op) {
      case '^':
        c ^= x;
        break;
      case '&':
        a &= x;
        b &= x;
        c &= x;
        break;
      case '|':
        b |= x;
        c &= ~x;
        break;
    }
  }
  printf(
      "3\n"
      "& %d\n"
      "| %d\n"
      "^ %d\n",
      a, b, c);
  return 0;
}
