#include <bits/stdc++.h>
using namespace std;
int n, k, tab[12], counter[5], res, j, op, i;
char t[2];
int main() {
  scanf("%d", &n);
  for (i = 0; i < 10; i++) tab[i] = 2;
  for (i = 0; i < n; i++) {
    scanf("%s %d", t, &k);
    if (t[0] == '&')
      for (j = 0; j < 10; j++)
        if (((1 << j) & k) == 0) tab[j] = 0;
    if (t[0] == '|')
      for (j = 0; j < 10; j++)
        if (((1 << j) & k) > 0) tab[j] = 1;
    if (t[0] == '^')
      for (j = 0; j < 10; j++)
        if (((1 << j) & k) > 0) {
          if (tab[j] == 0)
            tab[j] = 1;
          else if (tab[j] == 1)
            tab[j] = 0;
          else if (tab[j] == 2)
            tab[j] = 3;
          else if (tab[j] == 3)
            tab[j] = 2;
        }
  }
  for (i = 0; i < 4; i++) counter[i] = 0;
  for (i = 0; i < 10; i++) counter[tab[i]]++;
  res = 0;
  if (counter[0]) res++;
  if (counter[1]) res++;
  if (counter[3]) res++;
  printf("%d\n", res);
  if (counter[0]) {
    op = 1023;
    for (i = 0; i < 10; i++)
      if (tab[i] == 0) op -= (1 << i);
    printf("& %d\n", op);
  }
  if (counter[1]) {
    op = 0;
    for (i = 0; i < 10; i++)
      if (tab[i] == 1) op += (1 << i);
    printf("| %d\n", op);
  }
  if (counter[3]) {
    op = 0;
    for (i = 0; i < 10; i++)
      if (tab[i] == 3) op += (1 << i);
    printf("^ %d\n", op);
  }
  return 0;
}
