#include <bits/stdc++.h>
using namespace std;
ostream &ra(ostream &stream) {
  stream << " ------->";
  return stream;
}
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tc = 1;
  while (tc--) {
    long long n, k;
    cin >> n >> k;
    if (n <= k * (k - 1)) {
      cout << "YES" << endl;
      vector<long long> a(n), b(n);
      for (long long i = 0; i < n; i++) a[i] = (i % k) + 1;
      long long i = 0, x = 1, t;
      while (i < n) {
        long long j = 0;
        t = x;
        while (j < k && i < n) {
          b[i] = t % k;
          b[i]++;
          i++;
          j++;
          t++;
        }
        x++;
      }
      for (long long k = 0; k < n; k++) cout << a[k] << " " << b[k] << endl;
    } else {
      cout << "NO";
    }
  }
  return 0;
}
