#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > arr;
int main() {
  long long n, k;
  cin >> n >> k;
  if (n > k * (k - 1)) {
    cout << "NO";
    return 0;
  }
  long long g = 1, u = g + 1;
  cout << "YES" << endl;
  for (int i = 1; i <= n; i += 2) {
    if (u > k) {
      g++;
      u = g + 1;
    }
    cout << g << " " << u << endl;
    if (n % 2 == 1 && i == n) break;
    cout << u << " " << g << endl;
    u++;
  }
}
