#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, bool> m;
int main() {
  int n, k;
  cin >> n >> k;
  long long pos = 1LL * k * (k - 1);
  if (pos < n) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  int req = n;
  for (int i = 1; i <= k; i++) {
    for (int j = i + 1; j <= k; j++) {
      cout << i << " " << j << endl;
      m[make_pair(i, j)] = 1;
      req--;
      if (req == 0) {
        return 0;
      }
      if (m.find(make_pair(j, i)) == m.end()) {
        cout << j << " " << i << endl;
        m[make_pair(j, i)] = 1;
        req--;
        if (req == 0) {
          return 0;
        }
      }
    }
  }
  return 0;
}
