#include <bits/stdc++.h>
using namespace std;
unsigned nChoosek(unsigned n, unsigned k) {
  if (k > n) return 0;
  if (k * 2 > n) k = n - k;
  if (k == 0) return 1;
  int result = n;
  for (int i = 2; i <= k; ++i) {
    result *= (n - i + 1);
    result /= i;
  }
  return result;
}
int main() {
  int n, k;
  cin >> n >> k;
  int f, s;
  if (n > nChoosek(k, 2) * 2) {
    cout << "NO";
    return 0;
  }
  cout << "YES" << endl;
  f = 1;
  s = 2;
  bool b{0}, bb{0}, bb2{0};
  for (int i = 0; i < n; i++) {
    if (b == 0) {
      b = 1;
      if (bb == 0)
        cout << f << " " << s << endl;
      else
        cout << s << " " << f << endl;
    } else if (b == 1) {
      b = 0;
      if (bb == 1)
        cout << s << " " << f << endl;
      else
        cout << f << " " << s << endl;
      if (s == k) {
        f++;
        s = f + 1;
      } else
        s++;
    }
    bb = bb ^ 1;
  }
  return 0;
}
