#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long double PI = 4 * atan(1);
int n, fct[500001], x1[10], x2[10], x3[10], x4[10], cur;
char sym[500001];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> sym[i] >> fct[i];
  }
  for (int i = 0; i < 10; i++) {
    x1[i] = 0, x2[i] = 1, x3[i] = 1, x4[i] = 0;
    int res1 = 0, res2 = 1023;
    for (int j = 0; j < n; j++) {
      if (sym[j] == '|') {
        res1 = res1 | fct[j];
        res2 = res2 | fct[j];
      } else if (sym[j] == '&') {
        res1 = res1 & fct[j];
        res2 = res2 & fct[j];
      } else if (sym[j] == '^') {
        res1 = res1 ^ fct[j];
        res2 = res2 ^ fct[j];
      }
    }
    if (res1 & (1 << i)) {
      res1 = 1;
    } else {
      res1 = 0;
    }
    if (res2 & (1 << i)) {
      res2 = 1;
    } else {
      res2 = 0;
    }
    if (res1 == 1 && res2 == 1)
      x1[i] = 1;
    else if (res1 == 1 && res2 == 0)
      x4[i] = 1;
    else if (res1 == 0 && res2 == 0)
      x3[i] = 0;
    else {
      x2[i] = 1;
    }
  }
  cout << 4 << "\n";
  cout << '|' << " ";
  cur = 0;
  for (int i = 0; i < 10; i++) {
    cur += (pow(2, i) * x1[i]);
  }
  cout << cur << "\n";
  cout << '&' << " ";
  cur = 0;
  for (int i = 0; i < 10; i++) {
    cur += (pow(2, i) * x2[i]);
  }
  cout << cur << "\n";
  cout << '&' << " ";
  cur = 0;
  for (int i = 0; i < 10; i++) {
    cur += (pow(2, i) * x3[i]);
  }
  cout << cur << "\n";
  cout << '^' << " ";
  cur = 0;
  for (int i = 0; i < 10; i++) {
    cur += (pow(2, i) * x4[i]);
  }
  cout << cur << "\n";
  return 0;
}
