#include using namespace std; int main(){ int N, K; cin >> N >> K; int T; cin >> T; vector> C(T, vector(N)); for (int i = 0; i < T; i++){ for (int j = 0; j < N; j++){ cin >> C[i][j]; } } vector> op; for (int i = 0; i < T; i++){ vector p; for (int j = 0; j < N; j++){ if (C[i][j] == 1){ p.push_back(j); } } if (p.size() >= K){ vector A(N, false); for (int j = 0; j < K; j++){ A[p[j]] = true; } op.push_back(make_tuple("UPD", N, 1, 0)); for (int j = 0; j < K; j++){ op.push_back(make_tuple("AND", N, p[j], N)); } op.push_back(make_tuple("XOR", N, p[0], N)); for (int j = 0; j < N; j++){ if (!A[j]){ op.push_back(make_tuple("XOR", j, p[0], j)); op.push_back(make_tuple("AND", j, N, N)); op.push_back(make_tuple("XOR", j, p[0], j)); } } op.push_back(make_tuple("XOR", N, p[0], N)); } } int cnt = op.size(); assert(cnt <= 10000); cout << cnt << endl; for (int i = 0; i < cnt; i++){ if (get<0>(op[i]) == "UPD"){ cout << "UPD " << get<1>(op[i]) << ' ' << get<2>(op[i]) << endl; } if (get<0>(op[i]) == "AND"){ cout << "AND " << get<1>(op[i]) << ' ' << get<2>(op[i]) << ' ' << get<3>(op[i]) << endl; } if (get<0>(op[i]) == "XOR"){ cout << "XOR " << get<1>(op[i]) << ' ' << get<2>(op[i]) << ' ' << get<3>(op[i]) << endl; } } }