#include <bits/stdc++.h>
using namespace std;
vector<int> months = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int MAX = 1e5 + 55;
const int inf = 1e9 + 77;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double eps = 1e-7;
int main() {
  int n, k;
  scanf("%d", &n);
  scanf("%d", &k);
  if (n > (long long)k * (long long)(k - 1)) {
    printf("NO");
    return 0;
  }
  printf("YES\n");
  int need = n;
  for (int i = 1; i <= k && need; ++i) {
    for (int j = i + 1; j <= k && need; ++j) {
      printf("%d %d\n", i, j);
      --need;
      if (need) {
        printf("%d %d\n", j, i);
        --need;
      }
    }
  }
  return 0;
}
