#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int Q, K; cin >> Q >> K; vector> ops; auto no = [&]() { cout << "No\n"; exit(0); }; // K >= 5 なら任意の Q で可能 if (K >= 5) { cout << "Yes\n"; if (Q >= 1) ops.push_back({1, 2}); // 3 = z = ~(x&y) if (Q >= 2) ops.push_back({1, 2}); // 4 = z if (Q >= 3) ops.push_back({3, 4}); // 5 = x&y if (Q >= 4) ops.push_back({3, 5}); // 6 = 1 if (Q >= 5) ops.push_back({3, 5}); // 7 = 1 // 6,7 が定数 1 なので、以後 6 NAND 7 = 0 を出し続ける while ((int)ops.size() < Q) { ops.push_back({6, 7}); } for (auto [i, j] : ops) { cout << i << ' ' << j << '\n'; } return 0; } // K = 4 なら Q <= 5 まで可能 if (K == 4) { if (Q > 5) no(); cout << "Yes\n"; if (Q >= 1) ops.push_back({1, 2}); // z if (Q >= 2) ops.push_back({1, 2}); // z if (Q >= 3) ops.push_back({1, 2}); // z if (Q >= 4) ops.push_back({3, 4}); // x&y if (Q >= 5) ops.push_back({3, 4}); // x&y for (auto [i, j] : ops) { cout << i << ' ' << j << '\n'; } return 0; } // K = 3 なら Q <= 3 まで可能 if (K == 3) { if (Q > 3) no(); cout << "Yes\n"; if (Q >= 1) ops.push_back({1, 2}); // z if (Q >= 2) ops.push_back({1, 2}); // z if (Q >= 3) ops.push_back({3, 4}); // x&y for (auto [i, j] : ops) { cout << i << ' ' << j << '\n'; } return 0; } // K = 2 なら Q = 1 のみ可能 if (K == 2) { if (Q > 1) no(); cout << "Yes\n"; cout << "1 2\n"; return 0; } no(); }