#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-18;
const long double PI = 3.141592653589793238;
const long long MOD = 1e9 + 7;
int n;
long long k;
int main() {
  cin >> n >> k;
  if (k * (k - 1) < n) {
    return cout << "NO", 0;
  }
  int x = 1, y = 2, ok = 0;
  cout << "YES" << endl;
  for (int i = 0; i < n / 2; i++) {
    printf("%d %d\n%d %d\n", x, y, y, x);
    y++;
    if (y == k + 1) {
      x++, y = x + 1;
    }
  }
  if (n % 2) {
    printf("%d %d", x, y);
  }
}
