1
& 0
 1
^ 123
 10
^ 218
& 150
| 935
& 61
| 588
& 897
| 411
| 584
^ 800
| 704
 3
& 1
& 3
& 5
 1
| 123
 1
^ 0
 1
| 1023
 3
& 242
^ 506
^ 522
 10
^ 160
& 1021
& 510
^ 470
& 1022
& 251
& 760
& 1016
| 772
| 515
 1
& 1023
 1
| 0
 2
| 56
^ 875
 1
^ 1023
 2
| 999
^ 689
 3
^ 125
^ 377
& 1019
 1
& 123

3
& 0
| 0
^ 0
 3
& 1023
| 0
^ 123
 3
& 763
| 763
^ 0
 3
& 1
| 0
^ 0
 3
& 1023
| 123
^ 0
 3
& 1023
| 0
^ 0
 3
& 1023
| 1023
^ 0
 3
& 1010
| 768
^ 240
 2
| 775
^ 112
 3
& 1023
| 0
^ 0
 3
& 1023
| 0
^ 0
 3
& 983
| 16
^ 835
 3
& 1023
| 0
^ 1023
 3
& 350
| 326
^ 16
 3
& 1019
| 0
^ 256
 3
& 123
| 0
^ 0

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll inf = 1e18;
void solve() {
  int n;
  cin >> n;
  unsigned int xx = 42;
  unsigned int yy = xx;
  vector<int> state(10);
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    unsigned int x;
    cin >> x;
    bitset<10> bt(x);
    if (c == '|')
      xx |= x;
    else if (c == '&')
      xx &= x;
    else
      xx ^= x;
    for (int i = 0; i < bt.size(); i++) {
      if (bt[i] == 1) {
        if (c == '|') {
          state[i] = 1;
        } else if (c == '^') {
          if (state[i] == 0)
            state[i] = 3;
          else if (state[i] == 1)
            state[i] = 2;
          else if (state[i] == 2)
            state[i] = 1;
          else if (state[i] == 3)
            state[i] = 0;
        }
      } else {
        if (c == '&') {
          state[i] = 2;
        }
      }
    }
  }
  vector<int> pow2(10, 1);
  for (int i = 0; i < pow2.size(); i++) {
    for (int j = 0; j < i; j++) {
      pow2[i] *= 2;
    }
  }
  vector<pair<char, int> > ans;
  int a1 = 0;
  bool ff = 0;
  for (int i = 0; i < pow2.size(); i++) {
    if (state[i] == 1) {
      ff = 1;
      a1 += pow2[i];
    }
  }
  if (!ff) ans.push_back({'|', a1});
  int a2 = 0;
  bool f = 0;
  for (int i = 0; i < 10; i++) {
    if (state[i] != 2) {
      f = 1;
      a2 += pow2[i];
    }
  }
  if (!f) ans.push_back({'&', a2});
  int a3 = 0;
  f = 0;
  for (int i = 0; i < 10; i++) {
    if (state[i] == 3) {
      f = 1;
      a3 += pow2[i];
    }
  }
  if (!f) ans.push_back({'^', a3});
  cout << ans.size() << endl;
  for (auto p : ans) {
    char c = p.first;
    unsigned int x = p.second;
    if (c == '|')
      yy |= x;
    else if (c == '&')
      yy &= x;
    else
      yy ^= x;
    cout << p.first << ' ' << p.second << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
