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