#include <bits/stdc++.h>
const double PI = 3.1415926;
const int KL = 1e6;
using namespace std;
long long q, x, y, z, n, m, p[KL], k, mn = 1e9, mx = -1e9;
string t;
vector<long long> vec;
vector<pair<long long, long long>> ans;
set<int> s;
map<int, int> M;
int main() {
  scanf("%lld", &n);
  scanf("%lld", &k);
  if (k * (k - 1) < n) {
    cout << "NO" << endl;
    return 0;
  }
  x = 1, y = 2;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0 && i > 0) {
      if (y < k)
        y++;
      else {
        x++;
        y = x + 1;
      }
    }
    if (i % 2 == 0)
      ans.push_back({x, y});
    else
      ans.push_back({y, x});
  }
  cout << "YES" << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
