#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
long long int n, k;
int main() {
  cin >> n >> k;
  long long int num = k * (k - 1);
  if (n > num) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  int cnt = 0;
  for (int i = 1; i <= k; i++) {
    for (int j = i + 1; j <= k; j++) {
      cout << i << " " << j << endl;
      cnt++;
      if (cnt == n) return 0;
      cout << j << " " << i << endl;
      cnt++;
      if (cnt == n) return 0;
    }
  }
  return 0;
}
