#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  if (m * (m - 1) < n) {
    cout << "NO" << '\n';
    return 0;
  }
  int cnt = 0;
  cout << "YES" << '\n';
  for (int i = 1; i <= m - 1; i++) {
    for (int j = i + 1; j <= m; j++) {
      cnt++;
      cout << i << " " << j << '\n';
      if (cnt == n) {
        return 0;
      }
      cnt++;
      cout << j << " " << i << '\n';
      if (cnt == n) {
        return 0;
      }
    }
  }
}
