#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1e6 + 6;
int main() {
  int64_t n, k;
  cin >> n >> k;
  if ((k * (k - 1)) < n) {
    cout << "NO"
         << "\n";
    return 0;
  }
  cout << "YES"
       << "\n";
  for (int i = 1; i < k; i++) {
    for (int j = i + 1; j <= k; j++) {
      if (n == 0) break;
      cout << i << " " << j << '\n';
      n--;
      if (n == 0) break;
      cout << j << " " << i << '\n';
      n--;
    }
    if (n == 0) break;
  }
  return 0;
}
