#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  if ((k * (k - 1)) < n) {
    cout << "NO";
    return 0;
  }
  cout << "YES" << endl;
  long long count = 0;
  int i = 0;
  while (count < n) {
    int j = 0;
    while (j < k && count < n) {
      cout << (j % k) + 1 << " " << ((i + 1 + j) % k) + 1 << endl;
      j++;
      count++;
    }
    i++;
  }
}
