#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
vector<pair<int, int> > ans;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  if (n > k * (k - 1)) {
    cout << "NO" << '\n';
    return 0;
  }
  int x = 1, y = 2;
  while (n--) {
    ans.emplace_back(x, y);
    x++;
    x %= (k + 1);
    if (!x) x++;
    if (x == 1)
      y += 2;
    else
      y++;
    y %= (k + 1);
    if (!y) y++;
  }
  cout << "YES" << '\n';
  for (auto z : ans) cout << z.first << " " << z.second << '\n';
  return 0;
}
