#include <bits/stdc++.h>
using namespace std;
string ToBin(int x) {
  int n = x;
  string ans = "";
  while (n != 0) {
    int r = (n % 2);
    if (r == 1)
      ans += "1";
    else
      ans += "0";
    n /= 2;
  }
  while (ans.length() < 10) {
    ans += "0";
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
int BinToInt(string b) {
  int cp = 0;
  int ans = 0;
  for (int i = b.length() - 1; i >= 0; i--) {
    if (b[i] == '1') {
      ans += pow(2, cp);
    }
    cp++;
  }
  return ans;
}
int main() {
  vector<pair<string, char> > operations;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    char op;
    int operand;
    cin >> op >> operand;
    operations.push_back(make_pair(ToBin(operand), op));
  }
  vector<int> columnOperations;
  for (int column = 0; column < 10; column++) {
    int n1 = 0;
    for (int curOpIndex = 0; curOpIndex < n; curOpIndex++) {
      string curOpStr = operations[curOpIndex].first;
      char opType = operations[curOpIndex].second;
      if (opType == '|') {
        n1 = (n1 | (curOpStr[column] - '0'));
      } else if (opType == '^') {
        n1 = (n1 ^ (curOpStr[column] - '0'));
      } else {
        n1 = (n1 & (curOpStr[column] - '0'));
      }
    }
    int n2 = 1;
    for (int curOpIndex = 0; curOpIndex < n; curOpIndex++) {
      string curOpStr = operations[curOpIndex].first;
      char opType = operations[curOpIndex].second;
      if (opType == '|') {
        n2 = (n2 | (curOpStr[column] - '0'));
      } else if (opType == '^') {
        n2 = (n2 ^ (curOpStr[column] - '0'));
      } else {
        n2 = (n2 & (curOpStr[column] - '0'));
      }
    }
    if (n1 == 1 && n2 == 0) {
      columnOperations.push_back(2);
    } else if (n1 == 0 && n2 == 0) {
      columnOperations.push_back(0);
    } else if (n1 == 1 && n2 == 1) {
      columnOperations.push_back(1);
    } else {
      columnOperations.push_back(3);
    }
  }
  string firstOpStr = "";
  for (int i = 0; i < columnOperations.size(); i++) {
    if (columnOperations[i] == 0) {
      firstOpStr += "0";
    } else {
      firstOpStr += "1";
    }
  }
  string secondOpStr = "";
  for (int i = 0; i < columnOperations.size(); i++) {
    if (columnOperations[i] == 1) {
      secondOpStr += "1";
    } else {
      secondOpStr += "0";
    }
  }
  string thirdOpStr = "";
  for (int i = 0; i < columnOperations.size(); i++) {
    if (columnOperations[i] == 2) {
      thirdOpStr += "1";
    } else {
      thirdOpStr += "0";
    }
  }
  int firstOp = BinToInt(firstOpStr);
  int secondOp = BinToInt(secondOpStr);
  int thirdOp = BinToInt(thirdOpStr);
  int pl = 3;
  cout << pl << "\n";
  cout << "& " << firstOp << "\n";
  cout << "| " << secondOp << "\n";
  cout << "^ " << thirdOp << "\n";
  return 0;
}
