#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int n, k;
class Gen {
 public:
  Gen(int b) : ban{b}, seed(b) {}
  void exclude(int x) { ban.insert(x); }
  int operator()(int doNotUse) {
    int cur = seed;
    int iter = 0;
    while (iter <= k) {
      if (ban.count(cur) || cur == doNotUse) {
        cur = cur % k + 1;
        ++iter;
      } else {
        return cur;
      }
    }
    return 0;
  }
  bool hasAny() const { return k > (int)ban.size(); }
  set<int> ban;
  int seed;
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> k;
  vector<Gen> gens;
  for (int i = 0; i < k; ++i) {
    gens.emplace_back(i + 1);
  }
  if (n > i64(k) * i64(k - 1)) {
    cout << "NO";
    return 0;
  }
  vector<pair<int, int>> ans;
  int lastGirl = -1;
  while ((int)ans.size() < n) {
    bool fail = true;
    for (int i = 0; i < k && (int)ans.size() < n; ++i) {
      if (!gens[i].hasAny()) continue;
      int g = gens[i](lastGirl);
      if (g != 0) {
        gens[i].exclude(g);
        ans.emplace_back(i + 1, g);
        lastGirl = g;
        fail = false;
      }
    }
    if (fail) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES\n";
  for (const auto& p : ans) {
    cout << p.first << ' ' << p.second << '\n';
  }
  return 0;
}
