#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define mt make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; string YES = "YES", NO = "NO"; int N, M; void answer(int n) { int m = M - N + 1; rep(i, N)cout << i + 1 << (i != N - 1 ? ' ' : '\n'); vector E; for (int j = n + 1; j <= N; ++j) { E.emplace_back(1, j); } for (int i = 2; i <= n; ++i) { E.emplace_back(i, n + 1); } for (int i = 2; i <= n && m > 0; ++i) { for (int j = n + 2; j <= N && m > 0; ++j, --m) { E.emplace_back(i, j); } } assert(sz(E) == M); each(e, E) { cout << e.first << ' ' << e.second << endl; } } int main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> N >> M; if (M < N - 1) { cout << NO << endl; return 0; } for (int i = 1; i < N; ++i) { ll x = i, y = N - i; if (x*y >= M) { cout << YES << endl; answer(i); return 0; } } cout << NO << endl; }