#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
inline long long max3(long long a, long long b, long long c) {
  return (a) > (b) ? ((a) > (c) ? (a) : (c)) : ((b) > (c) ? (b) : (c));
}
inline long long min3(long long a, long long b, long long c) {
  return (a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c));
}
void solve() {
  long long int n, m, t = 0, k = 0, x = 0, y = 0, z = 0, a1, a2, a3, a4, a5, ex,
                      che, var = 0, yd, f = 9223372036854775807, templ, tempr;
  cin >> n >> k;
  vector<pair<long long int, long long int> > ans(n);
  set<pair<long long int, long long int> > st;
  y = 1;
  while (true) {
    ans[z].first = x + 1;
    ans[z].second = (x + y) % k + 1;
    st.insert(ans[z]);
    x = (x + 1) % k;
    if (x == 0) y++;
    z++;
    if (z == n) break;
  }
  if (st.size() != n || ans[n - 1].first == ans[n - 1].second) {
    cout << "No\n";
    return;
  }
  for (long long int(i) = 0; (i) < (n - 1); (i)++) {
    if (ans[i].first == ans[i + 1].first ||
        ans[i].second == ans[i + 1].second || ans[i].first == ans[i].second) {
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
  for (auto e : ans) {
    cout << e.first << " " << e.second << "\n";
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int T = 1, t = 0;
  while (t++ < T) {
    solve();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
}
