#include <bits/stdc++.h>
using namespace std;
void err() {
  cout << "NO\n";
  exit(0);
}
int main() {
  int n, i, j, t;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int k;
  cin >> n >> k;
  if (n > k * k - k) {
    cout << "NO";
  } else {
    vector<int> u, d;
    int sw = 0;
    for (i = 1; i < k + 1; i++) {
      for (j = i + 1; j < k + 1; j++) {
        u.push_back(i);
        u.push_back(j);
        d.push_back(j);
        d.push_back(i);
        if (u.size() >= n) goto jump;
      }
    }
  jump:
    cout << "YES\n";
    for (i = 0; i < n; i++) {
      cout << u[i] << " " << d[i] << '\n';
    }
  }
  return 0;
}
