#include <bits/stdc++.h>
using namespace std;
int n, a[500050], x[12];
char b[500050];
vector<int> Xor, Or, And;
int trans(int num, char opp, int bnum) {
  if (num == 0) {
    if (opp == '|') {
      return 0 | bnum;
    } else if (opp == '^') {
      return 0 ^ bnum;
    } else {
      return 0 & bnum;
    }
  } else if (num == 1) {
    if (opp == '|') {
      return 1 | bnum;
    } else if (opp == '^') {
      return 1 ^ bnum;
    } else {
      return 1 & bnum;
    }
  } else if (num == 2) {
    if (opp == '|') {
      if (bnum == 1) {
        return 1;
      } else {
        return num;
      }
    } else if (opp == '^') {
      if (bnum == 1) {
        return 3;
      } else {
        return 2;
      }
    } else {
      if (bnum == 1) {
        return 2;
      } else {
        return 0;
      }
    }
  } else {
    if (opp == '|') {
      if (bnum == 1) {
        return 1;
      } else {
        return 3;
      }
    } else if (opp == '^') {
      if (bnum == 1) {
        return 2;
      } else {
        return 3;
      }
    } else {
      if (bnum == 1) {
        return 3;
      } else {
        return 0;
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 12; i++) x[i] = 2;
  for (int i = 0; i < n; i++) {
    getchar();
    scanf("%c %d", &b[i], &a[i]);
    for (int j = 0; j < 12; j++) {
      int y = (1 << j) & a[i];
      if (y) y = 1;
      x[j] = trans(x[j], b[i], y);
    }
  }
  for (int i = 0; i < 10; i++) {
    if (x[i] == 1)
      Or.push_back(i);
    else if (x[i] == 0)
      And.push_back(i);
    else if (x[i] == 3)
      Xor.push_back(i);
  }
  printf("%d\n", 3);
  printf("| ");
  int curr = 0;
  for (auto next : Or) {
    curr += (1 << next);
  }
  printf("%d\n", curr);
  printf("& ");
  curr = 1023;
  for (auto next : And) {
    curr -= (1 << next);
  }
  printf("%d\n", curr);
  printf("^ ");
  curr = 0;
  for (auto next : Xor) {
    curr += (1 << next);
  }
  printf("%d\n", curr);
  return 0;
}
