#include <bits/stdc++.h>
using namespace std;
bool f[10][2];
int N;
int AND, XOR;
inline bool POS(int a, int pos) { return (((1 << pos) & a) != 0); }
int main() {
  cin >> N;
  char tipo;
  int c;
  for (int i = 0; i < 10; i++) f[i][0] = 0, f[i][1] = 1;
  while (N--) {
    cin >> tipo >> c;
    if (tipo == '&')
      for (int i = 0; i < 10; i++) {
        f[i][0] = (f[i][0] & POS(c, i));
        f[i][1] = (f[i][1] & POS(c, i));
      }
    else if (tipo == '|')
      for (int i = 0; i < 10; i++) {
        f[i][0] = (f[i][0] | POS(c, i));
        f[i][1] = (f[i][1] | POS(c, i));
      }
    else
      for (int i = 0; i < 10; i++) {
        f[i][0] = (f[i][0] ^ POS(c, i));
        f[i][1] = (f[i][1] ^ POS(c, i));
      }
  }
  for (int i = 0; i < 10; i++) {
    if (f[i][0] == 0 && f[i][1] == 0)
      ;
    if (f[i][0] == 0 && f[i][1] == 1) AND += (1 << i);
    if (f[i][0] == 1 && f[i][1] == 0) AND += (1 << i), XOR += (1 << i);
    if (f[i][0] == 1 && f[i][1] == 1) XOR += (1 << i);
  }
  cout << endl << "2" << endl << "& " << AND << endl << "^ " << XOR << endl;
  return 0;
}
