#include <bits/stdc++.h>
using namespace std;
pair<char, int> arr[500009];
int n;
char last;
int ans[20];
int get_bit(int pos, int val) { return ((1 << pos) & val); }
int calc(int pos, int start) {
  int ret = (start << pos);
  for (int i = 0; i < n; i++) {
    if (arr[i].first == '|') {
      ret |= (get_bit(pos, arr[i].second));
    } else if (arr[i].first == '^') {
      ret ^= (get_bit(pos, arr[i].second));
    } else {
      ret &= (get_bit(pos, arr[i].second));
    }
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf(" %c %d", &arr[i].first, &arr[i].second);
  }
  for (int i = 0; i < 10; i++) {
    int satu = calc(i, 1);
    int nol = calc(i, 0);
    if (!satu && !nol)
      ans[i] = 0;
    else if (satu && nol)
      ans[i] = 1;
    else if (satu && !nol)
      ans[i] = 2;
    else
      ans[i] = 3;
  }
  int dan = 1023, atau = 0, balik = 0;
  for (int i = 0; i < 10; i++) {
    if (ans[i] == 0) {
      dan ^= (1 << i);
    } else if (ans[i] == 1) {
      atau |= (1 << i);
    } else if (ans[i] == 3) {
      balik |= (1 << i);
    }
  }
  printf("3\n");
  printf("& %d\n", dan);
  printf("| %d\n", atau);
  printf("^ %d\n", balik);
}
