#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
void solve() {
  int n, k;
  cin >> n >> k;
  set<pair<int, int>> visited;
  pair<int, int> prev = {-1, -1};
  vector<pair<int, int>> ans;
  for (long long i = 0; i < n; i++) {
    int a = i % k + 1;
    int b = (i / k + a) % k + 1;
    if (a == b || visited.count({a, b}) || prev.first == a ||
        prev.second == b) {
      cout << "NO\n";
      return;
    }
    ans.push_back({a, b});
    visited.insert({a, b});
    prev = {a, b};
  }
  cout << "YES\n";
  for (auto it : ans) cout << it.first << ' ' << it.second << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
