#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  if (n > k * (k - 1))
    cout << "NO" << endl;
  else {
    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;
}
