#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5;
int x[maxn + 5], y[maxn + 5];
int n, k;
int main() {
  scanf("%d%d", &n, &k);
  if (n > 1LL * k * (k - 1))
    printf("NO\n");
  else {
    printf("YES\n");
    for (int i = 0; i < n; i++) {
      x[i] = i % k;
      y[i] = (x[i] + (i / k + 1)) % k;
    }
    for (int i = 0; i < n; i++) {
      x[i]++;
      y[i]++;
    }
    for (int i = 0; i < n; i++) printf("%d %d\n", x[i], y[i]);
  }
  return 0;
}
