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;
pair<char, int> pr[500100];
int arr[11];
map<vector<int>, int> mp;
vector<int> ans;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> pr[i].first;
    scanf("%d", &pr[i].second);
  }
  vector<int> ans;
  vector<int> tmp;
  for (int i = 0; i < 10; ++i) tmp.push_back(-1);
  mp[tmp] = 0;
  for (int i = 1; i <= n; ++i) {
    int x = pr[i].second;
    char c = pr[i].first;
    for (int j = 0; j < 10; ++j) {
      if (tmp[j] == -1) {
        if (c == '&') {
          if (x & (1 << j))
            tmp[j] = 1;
          else
            tmp[j] = 0;
        } else if (c == '|' && (x & (1 << j)))
          tmp[j] = 1;
        else if ((x & (1 << j)))
          tmp[j] = -2;
      } else if (tmp[j] == -2) {
        if (c == '&') {
          if (x & (1 << j))
            tmp[j] = 1;
          else
            tmp[j] = 0;
        } else if (c == '|' && (x & (1 << j)))
          tmp[j] = 1;
        else if ((x & (1 << j)))
          tmp[j] = -1;
      } else if (tmp[j] == 1) {
        if (c == '&') {
          if (x & (1 << j))
            tmp[j] = 1;
          else
            tmp[j] = 0;
        } else if (c == '|' && (x & (1 << j)))
          tmp[j] = 1;
        else if ((x & (1 << j)))
          tmp[j] = 0;
      } else {
        if (c == '&') {
          if (x & (1 << j))
            tmp[j] = 0;
          else
            tmp[j] = 0;
        } else if (c == '|' && (x & (1 << j)))
          tmp[j] = 1;
        else if ((x & (1 << j)))
          tmp[j] = 1;
      }
    }
  }
  int x1 = 0, x2 = 0, j = 0;
  for (int i = 0; i < 10; ++i, ++j) {
    if (tmp[i] == 0 || tmp[i] == 1) {
      x1 += (1 << j);
    }
    if (tmp[i] == 0 || tmp[i] == -2) x2 += (1 << j);
  }
  if (x1 == 0 && x2 == 0)
    cout << "0" << endl;
  else if (x2 == 0)
    cout << "1" << endl << "| " << x1 << endl;
  else if (x1 == 0)
    cout << "1" << endl << "^ " << x2 << endl;
  else
    cout << "2" << endl << "| " << x1 << endl << "^ " << x2 << endl;
  return 0;
}
