#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<array<int, 2>> ats;
  for (int i = 1; i <= k; i++)
    for (int j = i + 1; j <= k; j++) {
      ats.push_back({i, j});
      ats.push_back({j, i});
      if (ats.size() >= n) break;
    }
  if (ats.size() < n) return cout << "NO", 0;
  cout << "YES\n";
  for (int i = 0; i < n; i++) cout << ats[i][0] << " " << ats[i][1] << "\n";
}
