import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto X = new int[][](10, 2);
    foreach (i; 0..10) X[i][0] = 0;
    foreach (i; 0..10) X[i][1] = 1;

    foreach (i; 0..N) {
        auto s = readln.split;
        auto op = s[0];
        auto n = s[1].to!int;
        foreach (j; 0..10) {
            bool b = (n & (1 << j)) != 0;
            if (op[0] == '|') {
                X[j][0] |= b;
                X[j][1] |= b;
            } else if (op[0] == '&') {
                X[j][0] &= b;
                X[j][1] &= b;
            } else {
                X[j][0] ^= b;
                X[j][1] ^= b;
            }
        }
    }


    int opor = 0;
    int opand = 0;
    int opxor = 0;

    foreach (i; 0..10) {
        if (X[i][0] == 0 && X[i][1] == 0) {

        } else if (X[i][0] == 0 && X[i][1] == 1) {
            opand |= (1 << i);
        } else if (X[i][0] == 1 && X[i][1] == 0) {
            opand |= (1 << i);
            opxor |= (1 << i);
        } else {
            opor |= (1 << i);
            opand |= (1 << i);
        }
    }

    writeln(3);
    writeln("| ", opor);
    writeln("& ", opand);
    writeln("^ ", opxor);
}
