#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  while (cin >> n >> k) {
    if (n / k > k - 1) {
      cout << "NO" << endl;
      continue;
    } else if (n / k == k - 1) {
      if (n % k != 0) {
        cout << "NO" << endl;
        continue;
      }
    }
    cout << "YES" << endl;
    int t = 0;
    for (int i = 1; i <= k; i++) {
      for (int j = i + 1; j <= k; j++) {
        if (t >= n) break;
        cout << i << " " << j << endl;
        t++;
        if (t >= n) break;
        cout << j << " " << i << endl;
        t++;
      }
      if (t >= n) break;
    }
  }
}
