#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int dr8[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dc8[] = {1, -1, 0, 0, -1, 1, -1, 1};
int dr4[] = {0, 1, -1, 0};
int dc4[] = {1, 0, 0, -1};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  int on = 1023;
  cin >> n;
  int z = 0;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    int w;
    cin >> w;
    if (s[0] == '|') {
      z = z | w;
      on = on | w;
    } else if (s[0] == '^') {
      z = z ^ w;
      on = on ^ w;
    } else {
      z = z & w;
      on = on & w;
    }
  }
  int a[10];
  int x1 = 0, x2 = 1023, x3 = 0;
  for (int i = 0; i < 10; i++) {
    if (z % 2 == on % 2 && on % 2 == 1) {
      a[i] = 1;
      x1 = x1 ^ (1 << i);
    } else if (z % 2 == on % 2 && on % 2 == 0) {
      a[i] = 0;
      x2 = x2 ^ (1 << i);
    } else if (z % 2 == 1 && on % 2 == 0)
      x3 = x3 ^ (1 << i);
    z = z / 2;
    on = on / 2;
  }
  cout << 3 << endl;
  cout << "| " << x1 << endl;
  cout << "& " << x2 << endl;
  cout << "^ " << x3 << endl;
}
