#include <bits/stdc++.h>
using namespace std;
long long n, k, z[200005];
void Solve() {
  cin >> n >> k;
  if (n > k * (k - 1)) {
    cout << "NO";
    return;
  }
  for (long long i = 0, _b = k; i < _b; i++) z[i] = i + 1;
  cout << "YES\n";
  long long dau = -1;
  for (long long i = 1, _b = n; i <= _b; i++) {
    cout << (i - 1) % k + 1 << " ";
    if (i % k == 1) dau++;
    cout << z[(dau + i) % k] << "\n";
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int Test_numbers = 1;
  while (Test_numbers--) Solve();
  return 0;
}
