#include using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) using ll = long long; using P = std::tuple; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; int N, M; int values[100100]; set

edges; void addEdge(int u, int v){ edges.emplace(min(u, v), max(u, v)); } bool can(){ if(M < N - 1){ // 非連結になってしまう return false; } if(M <= 1ll * (N / 2) * ((N + 1) / 2)){ for(int i=1;i<=N;++i){ values[i] = i; if(edges.size() < M){ if(i <= N / 2){ addEdge(i, N / 2 + i); }else if(i < N / 2 * 2){ addEdge(i, i - N / 2 + 1); } } } if(N % 2 == 1){ addEdge(1, N); } for(int i=1;edges.size()> N >> M; if(can()){ std::cout << "YES" << std::endl; for(int i=1;i<=N;++i){ std::cout << values[i] << " \n"[i==N]; } for(const auto& p : edges){ int u, v; tie(u, v) = p; std::cout << u << " " << v << std::endl; } }else{ std::cout << "NO" << std::endl; } }