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;
long long delbit(long long a, int k) { return a & (~(1ll << k)); }
int delbit(int a, int k) { return a & (~(1 << k)); }
bool getbit(long long a, int k) { return 1 & (a >> k); }
bool getbit(int a, int k) { return 1 & (a >> k); }
bool getbit(unsigned long long a, int k) { return 1 & (a >> k); }
long long setbit(long long a, long long k) { return a |= (1 << k); }
int setbit(int a, int k) { return a |= (1 << k); }
inline long long mulmod(long long first, long long n, long long _mod) {
  long long res = 0;
  while (n) {
    if (n & 1) res = (res + first) % _mod;
    first = (first + first) % _mod;
    n >>= 1;
  }
  return res;
}
inline long long powmod(long long first, long long n, long long _mod) {
  long long res = 1;
  while (n) {
    if (n & 1) res = (res * first) % _mod;
    first = (first * first) % _mod;
    n >>= 1;
  }
  return res;
}
inline long long gcd(long long a, long long b) {
  long long t;
  while (b) {
    a = a % b;
    t = a;
    a = b;
    b = t;
  }
  return a;
}
inline int gcd(int a, int b) {
  int t;
  while (b) {
    a = a % b;
    t = a;
    a = b;
    b = t;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long gcd(long long a, long long b, long long c) {
  return gcd(gcd(a, b), c);
}
inline int gcd(int a, int b, int c) { return gcd(gcd(a, b), c); }
template <typename A, typename B>
ostream &operator<<(ostream &stream, const pair<A, B> &p) {
  stream << "{" << p.first << "," << p.second << "}";
  return stream;
}
template <typename A>
ostream &operator<<(ostream &stream, const vector<A> &v) {
  stream << "[";
  for (auto itr = v.begin(); itr != v.end(); itr++) stream << *itr << " ";
  stream << "]";
  return stream;
}
template <typename A, typename B>
ostream &operator<<(ostream &stream, const map<A, B> &v) {
  stream << "[";
  for (auto itr = v.begin(); itr != v.end(); itr++) stream << *itr << " ";
  stream << "]";
  return stream;
}
template <typename A>
ostream &operator<<(ostream &stream, const set<A> &v) {
  stream << "[";
  for (auto itr = v.begin(); itr != v.end(); itr++) stream << *itr << " ";
  stream << "]";
  return stream;
}
template <typename A>
ostream &operator<<(ostream &stream, const priority_queue<A> &v) {
  priority_queue<A> q = v;
  stream << "[";
  while (!q.empty()) {
    stream << q.top() << " ";
    q.pop();
  }
  stream << "]";
  return stream;
}
template <typename A>
ostream &operator<<(ostream &stream, const queue<A> &v) {
  queue<A> q = v;
  stream << "[";
  while (!q.empty()) {
    stream << q.front() << " ";
    q.pop();
  }
  stream << "]";
  return stream;
}
template <typename T, typename T2>
void printarr(T a[], T2 sz, T2 beg = 0) {
  for (T2 i = beg; i < sz; i++) cout << a[i] << " ";
  cout << endl;
}
char c[501001];
int num[501001];
int f1[12], f0[12];
vector<pair<char, int>> ans;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  fill(f1, f1 + 11, -1);
  fill(f0, f0 + 11, -1);
  int curor = 0;
  for (int(i) = (0); (i) < (n); (i)++) {
    cin >> c[i] >> num[i];
    if (c[i] == '&') {
      for (int(j) = (0); (j) < (11); (j)++) {
        if (!getbit(num[i], j)) {
          f1[j] = 0;
          f0[j] = 1;
        } else {
          if (f0[j]) {
            f1[j] = 0;
          }
        }
      }
    } else if (c[i] == '|') {
      for (int(j) = (0); (j) < (11); (j)++) {
        if (getbit(num[i], j)) {
          f1[j] = 1;
          f0[j] = 0;
        }
      }
    } else {
      for (int(j) = (0); (j) < (11); (j)++) {
        if (getbit(num[i], j)) {
          if (f1[j]) {
            f1[j] = 0;
            f0[j] = 1;
          } else {
            f1[j] = 1;
            f0[j] = 0;
          }
        }
      }
    }
  }
  int tmp = 0;
  for (int(i) = (0); (i) < (11); (i)++) {
    if (f1[i] < 0) continue;
    if (f1[i]) tmp |= (1 << i);
  }
  ans.push_back({'|', tmp});
  tmp = ((1 << 10) - 1);
  for (int(i) = (0); (i) < (11); (i)++) {
    if (f0[i] < 0) continue;
    if (f0[i]) tmp = delbit(tmp, i);
  }
  ans.push_back({'&', tmp});
  cout << ans.size() << endl;
  for (auto it : ans) {
    cout << it.first << " " << it.second << endl;
  }
  return 0;
}
