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