#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  vector<int> b(n + 1);
  if (n <= (k * (k - 1))) {
    cout << "YES" << endl;
    int i = 1;
    while (i < n + 1) {
      for (int j = 0; j < k && i < n + 1; j++) {
        a[i] = j + 1;
        i++;
      }
    }
    i = 1;
    int j = 1;
    while (i < n + 1) {
      for (int p = 0; p < k && i < n + 1; p++) {
        b[i] = (p + j) % k;
        i++;
      }
      j++;
    }
    for (int i = 1; i < n + 1; i++) {
      b[i]++;
    }
    for (int i = 1; i < n + 1; i++) {
      cout << a[i] << " " << b[i] << endl;
    }
  } else
    cout << "NO";
}
