#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  if (k * (k - 1) < n) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  pll bef = pll(-1, -1);
  ll c = 0;
  for (ll i = 1; i < (ll)k + 1; i++)
    for (ll j = i + 1; j < (ll)k + 1; j++) {
      pll cur = pll(i, j);
      if (bef.first == cur.first || bef.second == cur.second) {
        swap(cur.first, cur.second);
      }
      if (c + 1 == n) {
        cout << cur.first << " " << cur.second << endl;
        c++;
      } else {
        cout << cur.first << " " << cur.second << endl;
        cout << cur.second << " " << cur.first << endl;
        c += 2;
      }
      if (c == n) return 0;
      bef.first = cur.second;
      bef.second = cur.first;
    }
  return 0;
}
