#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int N, K;

void input_NK(void){
    cin >> N >> K;
}

void sort_xy(int x, int y, ostringstream& oss){
    oss << "UPD " << N << " 0" << endl;
    oss << "XOR " << N << " " << x << " " << N << endl;
    oss << "AND " << x << " " << x << " " << y << endl;
    oss << "XOR " << y << " " << y << " " << N << endl;
    oss << "XOR " << y << " " << x << " " << y << endl;
}

void sort_prefix(ostringstream& oss){
    string ret = "";
    for (int i = 0; i < N; ++i)
        for (int y = N - 1; y > i; --y)
            sort_xy(y - 1, y, oss);
}

string solve(void){
    ostringstream oss;
    sort_prefix(oss);
    oss << "UPD " << N << " 1" << endl;
    for (int i = N - 1; i >= N - K; --i)
        oss << "AND " << N << " " << i << " " << N << endl;
    return oss.str();
}

int main(void){
    input_NK();
    cout << solve();
    return 0;
}