#include using namespace std; using ll = long long; using P = pair; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; if (m < n - 1 || m > (n / 2) * (n - n / 2)) { cout << "NO" << endl; return 0; } vector a(n); for (int i = 0; i < n; i++) a[i] = i + 1; set

s; for (int i = 0; i < n / 2; i++) { s.emplace(i + 1, i + n / 2 + 1); } for (int i = n / 2; i < n; i++) { s.emplace(1, i + 1); } int cnt = n - 1; for (int i = 1; i < n / 2; i++) { for (int j = n / 2; j < n; j++) { if (cnt == m) break; P p(i + 1, j + 1); if (s.find(p) == s.end()) { s.insert(p); cnt++; if (cnt == m) break; } } if (cnt == m) break; } cout << "YES" << endl; cout << a[0]; for (int i = 1; i < n; i++) cout << " " << a[i]; cout << endl; for (auto& p : s) { cout << p.first << " " << p.second << endl; } return 0; }