#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
inline int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
inline int sub(int a, int b) {
  a -= b;
  if (a < 0) a += MOD;
  return a;
}
inline int mul(int a, int b) { return (int)((long long)a * b % MOD); }
inline int binpow(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b /= 2;
  }
  return res;
}
inline int inv(int a) { return binpow(a, MOD - 2); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  if (1ll * k * (k - 1) < n) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  int cnt = 0;
  for (int d = 1; d <= k - 1 && cnt < n; ++d) {
    for (int i = 0; i < k && cnt < n; ++i) {
      cout << i + 1 << " " << (i + d) % k + 1 << "\n";
      cnt++;
    }
  }
  return 0;
}
