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