#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int N;
  cin >> N;
  char c[N];
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> c[i] >> A[i];
  }
  if (N <= 5) {
    cout << N << endl;
    for (int i = 0; i < N; i++) cout << c[i] << " " << A[i] << endl;
  } else {
    string bitwise[N];
    for (int i = 0; i < N; i++) {
      int temp = A[i];
      while (temp != 0) {
        if (temp % 2 == 1)
          bitwise[i].push_back('1');
        else
          bitwise[i].push_back('0');
        temp /= 2;
      }
      while (bitwise[i].size() < 10) bitwise[i].push_back('0');
      reverse(bitwise[i].begin(), bitwise[i].end());
    }
    char for0[10], for1[10];
    int num;
    for (int i = 0; i < 10; i++) {
      num = 0;
      for (int j = 0; j < N; j++) {
        if (c[j] == '|')
          num |= (bitwise[j][i] - '0');
        else if (c[j] == '&')
          num &= (bitwise[j][i] - '0');
        else
          num ^= (bitwise[j][i] - '0');
      }
      if (num == 0)
        for0[i] = '0';
      else
        for0[i] = '1';
    }
    for (int i = 0; i < 10; i++) {
      num = 1;
      for (int j = 0; j < N; j++) {
        if (c[j] == '|')
          num |= (bitwise[j][i] - '0');
        else if (c[j] == '&')
          num &= (bitwise[j][i] - '0');
        else
          num ^= (bitwise[j][i] - '0');
      }
      if (num == 0)
        for1[i] = '0';
      else
        for1[i] = '1';
    }
    int bit1[10], bit2[10] = {}, bit3[10] = {};
    for (int i = 0; i < 10; i++) bit1[i] = 1;
    for (int i = 0; i < 10; i++) {
      if (for0[i] == '0' && for1[i] == '0')
        bit1[i] = 0;
      else if (for0[i] == '1' && for1[i] == '0')
        bit2[i] = 1;
      else if (for0[i] == '1' && for1[i] == '1')
        bit3[i] = 1;
    }
    int num1 = 0, num2 = 0, num3 = 0;
    for (int i = 0; i < 10; i++) {
      num1 += pow(2, i) * bit1[10 - i - 1];
    }
    for (int i = 0; i < 10; i++) {
      num2 += pow(2, i) * bit2[10 - i - 1];
    }
    for (int i = 0; i < 10; i++) {
      num3 += pow(2, i) * bit3[10 - i - 1];
    }
    cout << 3 << endl;
    cout << "& " << num1 << endl;
    cout << "^ " << num2 << endl;
    cout << "| " << num3 << endl;
  }
  return 0;
}
