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