#include <bits/stdc++.h>
using namespace std;
int x[200005];
int y[200005];
int main() {
  long long N, M, ok = 1, i, j, now = 3, how = 1;
  scanf("%lld %lld", &N, &M);
  now = 3;
  how = 1;
  x[0] = 2;
  x[1] = 1;
  for (i = 2; i < 200000; i++) {
    if (i % 2 == 0)
      x[i] = now;
    else {
      x[i] = how++;
      if (how == now) {
        now++;
        how = 1;
      }
    }
  }
  y[0] = 1;
  y[1] = 2;
  now = 3;
  how = 1;
  for (i = 2; i < 200000; i++) {
    if (i % 2 == 1) {
      y[i] = now;
      if (i + 1 == now * now - now) now++;
    } else {
      y[i] = how++;
      if (i + 2 == now * now - now) how = 1;
    }
  }
  if (M * M - M < N)
    printf("NO\n");
  else {
    printf("YES\n");
    for (i = 0; i < N; i++) printf("%d %d\n", x[i], y[i]);
  }
  return 0;
}
