#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int N = 1e5 + 10;
const int Mod = 0;
ll a[N];
ll n, m, T;
int Read();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  if (m * (m - 1) < n) {
    cout << "NO" << endl;
    return 0;
  } else {
    cout << "YES" << endl;
    for (int i = 1; i <= m; i++)
      for (int j = i + 1; j <= m; j++) {
        cout << i << " " << j << endl;
        if (!(--n)) return 0;
        cout << j << " " << i << endl;
        if (!(--n)) return 0;
      }
  }
  return 0;
}
int Read() {
  int val = 0, opt = 1;
  char ch;
  while (!isdigit(ch = getchar()))
    if (ch == '-') opt = -1;
  while (isdigit(ch)) (val *= 10) += ch - '0', ch = getchar();
  return val * opt;
}
