#include <bits/stdc++.h>
using namespace std;
vector<long long int> v;
void fun1(long long int n) {
  for (long long int i = 0; i < 10; ++i) {
    long long int b = (n >> i) & 1;
    if (b == 0) {
      v[i] = 0;
    } else {
    }
  }
}
void fun2(long long int n) {
  for (long long int i = 0; i < 10; ++i) {
    long long int b = (n >> i) & 1;
    if (b == 0) {
    } else {
      v[i] = 1;
    }
  }
}
void fun3(long long int n) {
  for (long long int i = 0; i < 10; ++i) {
    long long int b = (n >> i) & 1;
    if (b == 0) {
    } else {
      if (v[i] == 0) {
        v[i] = 1;
      } else if (v[i] == 1) {
        v[i] = 0;
      } else if (v[i] == 2) {
        v[i] = 3;
      } else {
        v[i] = 2;
      }
    }
  }
}
int main() {
  for (long long int i = 0; i < 10; ++i) v.push_back(2);
  long long int n;
  cin >> n;
  char ch;
  long long int tt;
  for (long long int i = 0; i < n; ++i) {
    cin >> ch >> tt;
    if (ch == '&') {
      fun1(tt);
    } else if (ch == '|') {
      fun2(tt);
    } else {
      fun3(tt);
    }
  }
  vector<pair<char, long long int> > aa;
  long long int ans = 0;
  long long int mul = 1;
  for (long long int i = 0; i < 10; ++i) {
    if (v[i] == 0) {
    } else {
      ans = ans + mul;
    }
    mul = mul * 2;
  }
  if (ans != 1023) aa.push_back({'&', ans});
  ans = 0;
  mul = 1;
  for (long long int i = 0; i < 10; ++i) {
    if (v[i] == 1) {
      ans = ans + mul;
    } else {
    }
    mul = mul * 2;
  }
  if (ans != 0) aa.push_back({'|', ans});
  ans = 0;
  mul = 1;
  for (long long int i = 0; i < 10; ++i) {
    if (v[i] == 3) {
      ans = ans + mul;
    } else {
    }
    mul = mul * 2;
  }
  if (ans != 0) aa.push_back({'^', ans});
  cout << aa.size() << endl;
  for (long long int i = 0; i < aa.size(); ++i)
    cout << aa[i].first << " " << aa[i].second << endl;
  return 0;
}
