#include <bits/stdc++.h>
using namespace std;
long long n, k;
int main() {
  cin >> n >> k;
  if (k * (k - 1) < n)
    cout << "NO" << endl;
  else {
    int a = 1, b = 2, c = 0, m = n;
    cout << "YES" << endl;
    while (m--) {
      if (!c) {
        printf("%d %d\n", a, b);
      } else {
        printf("%d %d\n", b, a);
        b++;
        if (b > k) {
          a++;
          b = a + 1;
        }
      }
      c = !c;
    }
  }
  return 0;
}
