#include <bits/stdc++.h>
using namespace std;
long long a[200005];
long long n, k;
void fail() {
  cout << "NO" << endl;
  exit(0);
}
void solve_6x6() {
  long long p[6] = {0, 1, 2, 3, 4, 5};
  long long px[6] = {1, 1, 2, 2, 3, 3};
  long long py[6] = {2, 3, 1, 3, 1, 2};
  if (n > 6) fail();
  for (long long m = 0; m < 2 * 3 * 4 * 5 * 6;
       m++, next_permutation(p, p + 6)) {
    long long good = true;
    for (long long i = 0; i < n && good; i++) {
      long long ni = (i + 1) % n;
      if (px[p[i]] == px[p[ni]]) good = false;
      if (py[p[i]] == py[p[ni]]) good = false;
    }
    if (!good) continue;
    cout << "YES"
         << "\n";
    for (long long i = 0; i < n; i++) {
      cout << px[p[i]] << " " << py[p[i]] << "\n";
    }
    exit(0);
  }
  fail();
}
void solve_hamilton() {
  vector<pair<long long, long long>> ans;
  if (k * k - k < n) fail();
  for (long long adn = 0; adn < 2 * k; adn++) {
    for (long long col = k - 1; col >= 0 && ans.size() < n; col--) {
      long long row = adn - col;
      if (row == col) continue;
      if (row < 0) continue;
      if (row >= k) continue;
      if (ans.size() + 1 == n) {
        if (col == ans[0].first) continue;
        if (row == ans[0].second) continue;
        if (col == ans.back().first) continue;
        if (row == ans.back().second) continue;
      }
      ans.push_back({col, row});
    }
  }
  assert(ans.size() == n);
  cout << "YES\n";
  for (long long i = 0; i < n; i++) {
    cout << ans[i].first + 1 << " " << ans[i].second + 1 << "\n";
  }
}
void solve() {
  cin >> n >> k;
  if (k == 2) {
    if (n == 2) {
      cout << "YES\n1 2\n2 1\n";
    } else {
      cout << "NO\n";
    }
    exit(0);
  }
  if (k == 3) {
    solve_6x6();
  } else {
    solve_hamilton();
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(20);
  solve();
  return 0;
}
