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>
namespace {
using i64 = long long;
using ui64 = unsigned long long;
using ui32 = unsigned int;
}  // namespace
int main() {
  int N;
  std::cin >> N;
  std::vector<std::pair<char, int>> arr(N);
  for (auto& el : arr) {
    std::cin >> el.first >> el.second;
  }
  std::pair<char, int> digs[10];
  ui32 a = 0;
  ui32 o = 0;
  ui32 x = 0;
  for (size_t i = 0; i < 10; ++i) {
    int flag = 0x01 << i;
    std::pair<char, int> cur(' ', -1);
    for (size_t i = 0; i < arr.size(); ++i) {
      if (arr[i].first == '&') {
        if ((arr[i].second & flag) != 0) {
          continue;
        }
        cur = arr[i];
      } else if (arr[i].first == '|') {
        if ((arr[i].second & flag) == 0) {
          continue;
        }
        cur = arr[i];
      } else {
        if ((arr[i].second & flag) == 0) {
          continue;
        }
        if (cur.first == '^') {
          cur.first = ' ';
        } else if (cur.first == '&') {
          cur.first = '|';
        } else if (cur.first == '|') {
          cur.first = '&';
        } else {
          cur.first = '^';
        }
      }
    }
    if (cur.first == '&') {
      a = a | flag;
    } else if (cur.first == '|') {
      o = o | flag;
    } else if (cur.first == '^') {
      x = x | flag;
    }
  }
  int count = 0;
  if (a != 0) ++count;
  if (o != 0) ++count;
  if (x != 0) ++count;
  std::cout << count << std::endl;
  if (a != 0) std::cout << "& " << (~a & 0x3FF) << std::endl;
  if (o != 0) std::cout << "| " << o << std::endl;
  if (x != 0) std::cout << "^ " << x << std::endl;
  return 0;
}
