#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
int main() {
  int n;
  scanf("%d", &n);
  char ch;
  int x;
  int n0 = 0, n1 = (1 << 10) - 1;
  for (int i = (1); i <= (n); i++) {
    while (ch = getchar(), ch != '|' && ch != '&' && ch != '^')
      ;
    scanf("%d", &x);
    if (ch == '|')
      n0 |= x, n1 |= x;
    else if (ch == '&')
      n0 &= x, n1 &= x;
    else if (ch == '^')
      n0 ^= x, n1 ^= x;
  }
  int ans0 = 0, ans1 = 0, ans2 = 0;
  for (int i = (0); i <= (9); i++) {
    if ((n0 & (1LL << (i))) || (n1 & (1LL << (i)))) ans0 |= (1LL << (i));
    if ((n0 & (1LL << (i))) && (n1 & (1LL << (i)))) ans1 |= (1LL << (i));
    if ((n0 & (1LL << (i))) && !(n1 & (1LL << (i)))) ans2 |= (1LL << (i));
  }
  printf("3\n& %d\n| %d\n^ %d\n", ans0, ans1, ans2);
  return 0;
}
