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