#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  if (k * (k - 1) < n) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  long long flag = 2;
  long long i = 1;
  long long tmp = 2;
  while (n--) {
    cout << i << " " << tmp << endl;
    i++;
    tmp++;
    if (i == k + 1) i = 1;
    if (tmp == flag) {
      tmp = flag + 1;
      flag++;
    }
    if (tmp == k + 1) tmp = 1;
  }
}
