#include <bits/stdc++.h>
using namespace std;
const int N = 10;
const int MAXA = 1023;
int n, sta[N], a, b, c;
void Do(char c, int x) {
  if (c == '&') {
    for (int i = 0; i < N; ++i)
      if ((x >> i & 1) == 0) sta[i] = 0;
  } else if (c == '^') {
    for (int i = 0; i < N; ++i)
      if (x >> i & 1) sta[i] ^= 1;
  } else if (c == '|') {
    for (int i = 0; i < N; ++i)
      if (x >> i & 1) sta[i] = 1;
  }
}
int main() {
  scanf("%d", &n);
  memset(sta, -1, sizeof(sta));
  for (int i = 1; i <= n; ++i) {
    char c = getchar();
    while (c != '|' && c != '^' && c != '&') c = getchar();
    int x;
    scanf("%d", &x);
    Do(c, x);
  }
  a = MAXA;
  b = c = 0;
  for (int i = 0; i < N; ++i) {
    if (sta[i] == 0)
      a ^= 1 << i;
    else if (sta[i] == 1)
      b ^= 1 << i;
    else if (sta[i] == -2)
      c ^= 1 << i;
  }
  printf("3\n& %d\n| %d\n^ %d\n", a, b, c);
  return 0;
}
