#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
long long n, k;
int main() {
  cin >> n >> k;
  long long total = (k - 1) * k;
  if (total < n) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  long long ptr = 0;
  for (long long lf = 1; lf <= k; lf++) {
    for (long long rg = lf + 1; rg <= k; rg++) {
      if (ptr == n) break;
      cout << lf << " " << rg << "\n";
      ptr++;
      if (ptr == n) break;
      cout << rg << " " << lf << "\n";
      ptr++;
    }
  }
}
