#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using lld = long double;
const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> k >> n;
  vector<pair<int, int> > ans;
  for (int dif = 1; dif < n; dif++) {
    for (int i = 0; i < n; i++) {
      ans.emplace_back(i, (i + dif) % n);
      if (ans.size() == k) break;
    }
    if (ans.size() == k) break;
  }
  if (ans.size() != k) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (int i = 0; i < k; i++)
    cout << ans[i].first + 1 << " " << ans[i].second + 1 << '\n';
  return 0;
}
