#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
long long n, m;
int main() {
  scanf("%lld%lld", &n, &m);
  if (n > m * (m - 1)) {
    puts("NO");
    return 0;
  }
  puts("YES");
  int cnt = 0;
  for (int i = m; i >= 2; i--) {
    for (int j = i - 1; j > 0; j--) {
      printf("%d %d\n", i, j);
      cnt++;
      if (cnt == n) return 0;
      printf("%d %d\n", j, i);
      cnt++;
      if (cnt == n) return 0;
    }
  }
  return 0;
}
