#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
void solve() {
  int n, k;
  cin >> n >> k;
  long long total = ((long long)k) * ((long long)k - 1);
  if (n > total) {
    cout << "NO";
    return;
  }
  vector<pair<int, int> > arr;
  for (int i = 1; i <= k && arr.size() < n; i++) {
    for (int j = i + 1; j <= k && arr.size() < n; j++) {
      if (arr.size() < n) arr.push_back({i, j});
      if (arr.size() < n) arr.push_back({j, i});
    }
  }
  cout << "YES" << endl;
  for (int i = 0; i < arr.size(); i++) {
    cout << arr[i].first << " " << arr[i].second << endl;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
}
