Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.

In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an arbitrary sequence of these operations with arbitrary constants from 0 to 1023. When the program is run, all operations are applied (in the given order) to the argument and in the end the result integer is returned.

Petya wrote a program in this language, but it turned out to be too long. Write a program in CALPAS that does the same thing as the Petya's program, and consists of no more than 5 lines. Your program should return the same integer as Petya's program for all arguments from 0 to 1023.

Input

The first line contains an integer n (1 ≤ n ≤ 5·105) — the number of lines.

Next n lines contain commands. A command consists of a character that represents the operation ("&", "|" or "^" for AND, OR or XOR respectively), and the constant xi 0 ≤ xi ≤ 1023.

Output

Output an integer k (0 ≤ k ≤ 5) — the length of your program.

Next k lines must contain commands in the same format as in the input.

Examples

Input

3
| 3
^ 2
| 1


Output

2
| 3
^ 2


Input

3
&amp; 1
&amp; 3
&amp; 5


Output

1
&amp; 1


Input

3
^ 1
^ 2
^ 3


Output

0

Note

You can read about bitwise operations in <https://en.wikipedia.org/wiki/Bitwise_operation>.

Second sample:

Let x be an input of the Petya's program. It's output is ((x&1)&3)&5 = x&(1&3&5) = x&1. So these two programs always give the same outputs.
#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1e9 + 7;
long long int INF = 1e18;
long long int sub(long long int a, long long int b, long long int p = MOD) {
  return ((a % p) - (b % p) + p) % p;
}
long long int mult(long long int a, long long int b, long long int p = MOD) {
  return ((a % p) * (b % p)) % p;
}
long long int add(long long int a, long long int b, long long int p = MOD) {
  return (a % p + b % p) % p;
}
long long int fpow(long long int n, long long int k, long long int p = MOD) {
  long long int r = 1;
  while (k > 0) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
    k = k >> 1;
  }
  return r;
}
long long int inv(long long int a, long long int p = MOD) {
  return fpow(a, p - 2, p);
}
long long int fdiv(long long int a, long long int b, long long int p = MOD) {
  long long int yinv = inv(b);
  long long int ans = (a * yinv) % p;
  return ans;
}
unsigned long long int I1018 = 1000000000000000000;
const unsigned long long int I10e5 = 100000;
const long long int I10e6 = 1e6;
void printVecpll(std::vector<pair<long long int, long long int>> v) {
  for (auto p : v) {
    cout << p.first << " " << p.second << endl;
  }
}
template <typename T>
istream &operator>>(istream &in, vector<T> &a) {
  for (auto &item : a) {
    in >> item;
  }
  return in;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> &a) {
  for (auto &item : a) {
    out << item << " ";
  }
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, vector<vector<T>> &a) {
  for (auto &item : a) {
    out << item << "\n";
  }
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, set<T> &a) {
  for (auto &item : a) {
    out << (char)item << " ";
  }
  return out;
}
std::vector<bool> is_prime;
std::vector<long long int> primes;
void sieve(long long int n) {
  is_prime.resize(n + 2, true);
  primes.clear();
  long long int p;
  for (p = 2; p * p <= n; p++) {
    if (is_prime[p]) {
      long long int i;
      for (i = p * p; i <= n; i += p) {
        is_prime[i] = false;
      }
    }
  }
  is_prime[0] = is_prime[1] = false;
  long long int i;
  for (i = 2; i <= n; i++) {
    if (is_prime[i]) {
      primes.emplace_back(i);
    }
  }
}
set<long long int> prime_factor(long long int n) {
  sieve(n);
  long long int i;
  set<long long int> s;
  for (auto p : primes) {
    if (p > sqrt(n)) break;
    while (n % p == 0 && n > 1) {
      s.insert(p);
      n /= p;
    }
  }
  if (n > 1) {
    s.insert(n);
  }
  return s;
}
int main() {
  long long int i;
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int n;
  cin >> n;
  std::vector<long long int> v(10, 2);
  for (i = 0; i < n; i++) {
    char ch;
    long long int t;
    cin >> ch >> t;
    long long int j;
    if (ch == '|') {
      for (j = 0; j < 10; j++) {
        if (t & (1ll << j)) {
          v[j] = 1;
        }
      }
    } else if (ch == '&') {
      for (j = 0; j < 10; j++) {
        if (!(t & (1ll << j))) {
          v[j] = 0;
        }
      }
    } else {
      for (j = 0; j < 10; j++) {
        if (t & (1ll << j)) {
          v[j] ^= 1;
        }
      }
    }
  }
  long long int v1 = 0, v2 = 0, v3 = 0;
  for (i = 0; i < 10; i++) {
    if (v[i] == 0) v1 |= (1ll << i);
    if (v[i] == 1) v2 |= (1ll << i);
    if (v[i] == 3) v3 |= (1ll << i);
  }
  cout << 3 << endl;
  cout << "| " << v2 << endl;
  cout << "& " << (1023 ^ v1) << endl;
  cout << "^ " << v3 << endl;
  return 0;
}
