#include <bits/stdc++.h>
using namespace std;
const long long oo = (long long)1e18;
const int mod = (int)1e9 + 7;
const double PI = acos((long long)-1.0);
class TaskA {
 public:
  void solve(std::istream& in, std::ostream& out) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a[15];
    fill(a, a + 11, 3);
    in >> n;
    for (int i = 0; i < n; ++i) {
      char c;
      int x;
      in >> c >> x;
      if (c == '^') {
        for (int j = 0; j < 10; ++j) {
          if ((1 << j) & x) {
            if (a[j] == 0)
              a[j] = 1;
            else if (a[j] == 1)
              a[j] = 0;
            else if (a[j] == 2)
              a[j] = 3;
            else if (a[j] == 3)
              a[j] = 2;
          }
        }
      }
      if (c == '&') {
        for (int j = 0; j < 10; ++j) {
          if (((1 << j) & x) == 0) a[j] = 0;
        }
      }
      if (c == '|') {
        for (int j = 0; j < 10; ++j) {
          if ((1 << j) & x) a[j] = 1;
        }
      }
    }
    int x = 0, y = 1023, z = 0;
    for (int i = 0; i < 10; ++i) {
      if (a[i] == 0) y = y - (1 << i);
      if (a[i] == 1) z = z + (1 << i);
      if (a[i] == 2) x = x + (1 << i);
    }
    out << 3 << "\n";
    out << "& " << y << "\n";
    out << "^ " << x << "\n";
    out << "| " << z << "\n";
  };
};
int main() {
  TaskA solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
