#include <bits/stdc++.h>
using namespace std;
struct pos {
  char c;
  int a;
} ans[10];
int wz[1505];
map<int, int> mp;
int main() {
  int n;
  scanf("%d", &n);
  int res = 0;
  res += 1;
  char s[3];
  int a;
  int sum1 = 0, sum2 = 1023;
  for (int i = 0; i < n; i++) {
    scanf("%s%d", &s, &a);
    if (s[0] == '&') {
      sum1 &= a;
      sum2 &= a;
    }
    if (s[0] == '|') {
      sum1 |= a;
      sum2 |= a;
    }
    if (s[0] == '^') {
      sum1 ^= a;
      sum2 ^= a;
    }
  }
  int ans1, ans2, ans3;
  ans1 = ans2 = ans3 = 0;
  for (int i = 1; i <= 10; i++) {
    int num1 = sum1 & 1;
    int num2 = sum2 & 1;
    if (num1 == 0) {
      if (num2 == 1) {
        ans1 += 0;
        ans2 += res;
        ans3 += 0;
      }
    } else {
      if (num2 == 1) {
        ans1 += 0;
        ans2 += res;
        ans3 += res;
      } else {
        ans1 += res;
        ans2 += res;
        ans3 += 0;
      }
    }
    sum1 >>= 1;
    sum2 >>= 1;
    res <<= 1;
  }
  printf("3\n");
  printf("^ %d\n& %d\n| %d\n", ans1, ans2, ans3);
}
