#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
constexpr ll INF = 1000000000;
void solve(istream &cin) {
  ll N;
  if (!(cin >> N)) {
    return;
  }
  ll K;
  cin >> K;
  if (K * (K - 1) < N) {
    cout << "NO\n";
    return;
  }
  cout << "YES\n";
  int count = 0;
  for (int i = 1; i <= K; ++i) {
    for (int j = i + 1; j <= K; ++j) {
      cout << i << ' ' << j << '\n';
      count++;
      if (count == N) {
        return;
      }
      cout << j << ' ' << i << '\n';
      count++;
      if (count == N) {
        return;
      }
    }
  }
}
int main(int argc, char *argv[]) {
  string FileName("E"), Modifier("MEPH_");
  string ExecutionName = Modifier + FileName;
  string sub(argv[0]);
  if (sub.size() > ExecutionName.size())
    sub = sub.substr(sub.size() - ExecutionName.size(), ExecutionName.size());
  cout << setprecision(16) << scientific;
  if (sub != ExecutionName) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while (cin) {
      solve(cin);
    }
  } else {
    cerr << sub << " test" << endl;
    string inFile = FileName + ".txt";
    auto fs = fstream(inFile, fstream::in);
    while (fs) {
      solve(fs);
    }
  }
}
