#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, k;
  cin >> n >> k;
  long long curr_r = 2, curr_l = 1;
  bool swp = false;
  vector<pair<long long, long long>> ans;
  for (long long i = 1; i <= n; i++) {
    if (swp) {
      ans.push_back({curr_r, curr_l});
    } else {
      ans.push_back({curr_l, curr_r});
    }
    if (swp) {
      curr_l++;
      if (curr_l == curr_r) {
        curr_r++;
        curr_l = 1;
      }
    }
    swp ^= 1;
  }
  long long mx = 0;
  for (auto [l, r] : ans) {
    mx = max(mx, l);
    mx = max(mx, r);
  }
  if (mx > k) {
    cout << "NO";
  } else {
    cout << "YES\n";
    for (auto [l, r] : ans) {
      cout << l << ' ' << r << '\n';
    }
  }
  return 0;
}
