#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, j, k, h = 0, n;
  cin >> n >> k;
  if (n > (k - 1) * (k)) {
    cout << "NO";
    return 0;
  }
  cout << "YES";
  cout << endl;
  long long int b[n], g[n];
  j = 1;
  for (i = 0; i < n; ++i) {
    b[i] = (i % k) + 1;
    g[i] = (b[i] + j) % k;
    if (g[i] == 0) g[i] = k;
    cout << b[i] << ' ' << g[i];
    cout << endl;
    if (b[i] == k) j++;
  }
  return 0;
}
