#pragma GCC optimize("Ofast", "unroll-loops") #include using namespace std; int N, K; void input_NK(void){ cin >> N >> K; } void sort_xy(int x, int y, ostringstream& oss, int& op){ 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; op += 5; } void sort_prefix(ostringstream& oss, int& op){ string ret = ""; for (int i = 0; i < N; ++i) for (int y = N - 1; y > i; --y) sort_xy(y - 1, y, oss, op); } string solve(int& op){ ostringstream oss; op = 0; sort_prefix(oss, op); oss << "UPD " << N << " 1" << endl; for (int i = N - 1; i >= N - K; --i) oss << "AND " << N << " " << i << " " << N << endl; op += K + 1; return oss.str(); } int main(void){ input_NK(); int op; string ans = solve(op); cout << op << endl << ans; return 0; }