#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  scanf("%lld", &n), scanf("%lld", &k);
  long long val = (k * (k - 1));
  if (val < n) {
    printf("NO\n");
    return 0;
  } else {
    printf("YES\n");
    long long l = 1, r = l + 1, t = k - 1, cnt = 0;
    for (long long i = 1; i <= n; i++) {
      if (i & 1) {
        cnt++;
        cout << l << ' ' << r << endl;
      } else {
        cout << r << ' ' << l << endl;
        r++;
        if (cnt == t) {
          cnt = 0;
          t--;
          l++;
          r = l + 1;
        }
      }
    }
  }
}
