#include <bits/stdc++.h>
using namespace std;
int n, x, a = 0, b = 1023;
char ch;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    getchar();
    ch = getchar();
    scanf("%d", &x);
    if (ch == '&')
      a &= x, b &= x;
    else if (ch == '|')
      a |= x, b |= x;
    else if (ch == '^')
      a ^= x, b ^= x;
  }
  int ans1 = 0, ans2 = 0;
  x = 1;
  for (int i = 1; i <= 10; i++) {
    if ((a & x) && (b & x)) ans1 += x;
    if ((a & x) && (!(b & x))) ans2 += x;
    if ((!(a & x)) && (!(b & x))) ans1 += x, ans2 += x;
    x <<= 1;
  }
  printf("2\n");
  printf("| %d\n", ans1);
  printf("^ %d\n", ans2);
  return 0;
}
