#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  if (k < n) {
    if ((n / k) < (k - 1) || (k * (k - 1) == n)) {
      cout << "YES" << endl;
      long long s = 1;
      for (long long i = 1; i <= n; i++) {
        if (i % k != 0 && (i + s) % k != 0)
          cout << i % k << " " << (i + s) % k << endl;
        else if (i % k != 0 && (i + s) % k == 0)
          cout << i % k << " " << k << endl;
        else if (i % k == 0 && (i + s) % k != 0) {
          cout << k << " " << (i + s) % k << endl;
          s++;
        }
      }
    } else
      cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
    if (k == n) {
      for (long long i = 1; i <= n; i++)
        if (i % n != 0)
          cout << i << " " << i + 1 << endl;
        else
          cout << i << " " << 1 << endl;
    } else {
      for (long long i = 1; i <= n; i++) cout << i << " " << i + 1 << endl;
    }
  }
  return 0;
}
