#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long maxi = k * (k - 1);
  if (n > maxi) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  long long curr = 0;
  for (long long i = 0; i < n; i++) {
    curr += (i % k == 0);
    cout << (i % k + 1) << " " << (curr + i % k) % k + 1 << "\n";
  }
  return 0;
}
