Problem: 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.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <typename X>
inline X abs(const X& a) {
  return a < 0 ? -a : a;
}
template <typename X>
inline X sqr(const X& a) {
  return a * a;
}
const int size = 1e5 + 2;
const double eps = 0.0001;
const long double PI = 3.1415926535897932384626433832795;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const long long MAX5 = 100001;
const long long MAX6 = 1000001;
const long long MAX17 = 99999999999999999;
const double DMAX = 2e18 + 5;
int solution();
void include_file();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  return solution();
  return 0;
}
void include_file() {
  ios_base::sync_with_stdio(true);
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
inline bool isPrime(long long n) {
  for (int i = 2; i * i <= n; ++i)
    if (n % i == 0) return false;
  return true;
}
string ekv(string a) {
  if (a.size() & 1) return a;
  string x = ekv(a.substr(0, a.size() / 2));
  string y = ekv(a.substr(a.size() / 2));
  return min(x + y, y + x);
}
long long cubic_root(long long x) {
  long long l = 0, r = MAX6;
  while (l != r) {
    long long m = (l + r + 1) / 2;
    if (m * m * m > x)
      r = m - 1;
    else
      l = m;
  }
  return l;
}
float FastInvSqrt(float x) {
  float xhalf = 0.5f * x;
  int i = *(int*)&x;
  i = 0x5f3759df - (i >> 1);
  x = *(float*)&i;
  x = x * (1.5f - (xhalf * x * x));
  return x;
}
long long gcd(long long a, long long b) {
  while (b ^= a ^= b ^= a = a % b)
    ;
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
void yes() { cout << "YES"; }
void no() { cout << "NO"; }
void yes(bool res, bool small = false) {
  if (!small) {
    if (res)
      cout << "YES";
    else
      cout << "NO";
  } else {
    if (res)
      cout << "Yes";
    else
      cout << "No";
  }
}
void dabl(double x) { printf("%.10lf", x); }
namespace bits {
template <typename X>
inline X MAX(const X& a, const X& b) {
  return b & ((a - b) >> 31) | a & (~(a - b) >> 31);
}
template <typename X>
inline X MIN(const X& a, const X& b) {
  return a & ((a - b) >> 31) | b & (~(a - b) >> 31);
}
bool check2(const long long n) { return n > 0 && (n & (n - 1)); }
long long ostatok2(const long long n, const long long m) { return m & (n - 1); }
template <typename X>
void SWAP(X& a, X& b) {
  a ^= b;
  b ^= a;
  a ^= b;
}
size_t count_1_in_LL(unsigned long long n) {
  std::size_t i(0);
  for (; n; ++i) n &= n - 1;
  return i;
}
}  // namespace bits
void debug() {}
template <typename H, typename... T>
void debug(H p, T... t) {
  std::cout << p << " ";
  debug(t...);
}
vector<vector<int> > g;
inline int solution() {
  int n;
  cin >> n;
  char op[n];
  int v[n];
  int y = 1023, x = 0;
  for (long long i = 0; i < n; ++i) {
    cin >> op[i] >> v[i];
    if (op[i] == '|')
      x |= v[i], y |= v[i];
    else if (op[i] == '&')
      x &= v[i], y &= v[i];
    else
      x ^= v[i], y ^= v[i];
  }
  int andv = 0, orv = 0, xorv = 0;
  for (long long i = 0; i < 10; ++i) {
    int k = 1 << i;
    if ((x & k) && (y & k))
      orv += k;
    else if (!(x & k) && !(y & k))
      orv += k, xorv += k;
    else if ((x & k) && !(y & k))
      xorv += k;
  }
  cout << 2 << endl;
  cout << "| " << orv << endl;
  cout << "^ " << xorv << endl;
  return 0;
}