#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (int i = 0; i < v.size(); ++i) {
    os << v[i];
    if (i != v.size() - 1) os << ", ";
  }
  os << "]\n";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  os << "[";
  for (auto it : v) {
    os << it;
    if (it != *v.rbegin()) os << ", ";
  }
  os << "]\n";
  return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v) {
  for (auto it : v) os << it.first << " : " << it.second << "\n";
  return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v) {
  os << "(";
  os << v.first << ", " << v.second << ")";
  return os;
}
void go() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int32_t main() {
  go();
  long long n, k;
  cin >> n >> k;
  if (n > (k * (k - 1))) {
    cout << "NO" << '\n';
    return 0;
  }
  vector<pair<long long, long long>> ans;
  while (ans.size() < n) {
    for (long long i = 1; i < k; i++) {
      for (long long j = i + 1; j <= k; j++) {
        ans.push_back({i, j});
        ans.push_back({j, i});
        if (ans.size() > n) break;
      }
    }
  }
  cout << "YES" << '\n';
  for (long long i = 0; i < n; i++)
    cout << ans[i].first << ' ' << ans[i].second << '\n';
}
