#include <bits/stdc++.h>
const int N = 500;
using namespace std;
int n, yh, yhuo = 0, huo = 0, yu, x = 0, y;
char pd;
int main() {
  y = 1023;
  x = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    cin >> pd >> yh;
    if (pd == '&') x &= yh, y &= yh;
    if (pd == '|') x |= yh, y |= yh;
    if (pd == '^') x ^= yh, y ^= yh;
  }
  huo = 0;
  yhuo = 0;
  for (int i = 0; i <= 9; i++) {
    int a = x & (1 << i), b = y & (1 << i);
    if (a && b == 0) yhuo |= (1 << i);
    if (a == 0 && b == 0) huo |= (1 << i), yhuo |= (1 << i);
    if (a && b) huo |= (1 << i);
  }
  printf("2\n");
  printf("| %d\n^ %d\n", huo, yhuo);
  return 0;
}
