#include <bits/stdc++.h>
using namespace std;
void PT(long long a);
void PT1(long long a);
const long long M = 2 * (1e5) + 7;
long long a[M];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  {
    long long n, k;
    cin >> n >> k;
    if (k * (k - 1) < n)
      return cout << "NO"
                  << "\n",
             0;
    cout << "YES"
         << "\n";
    vector<pair<long long, long long>> v;
    long long i = 1, j = 2;
    while (v.size() < n) {
      if (v.size() == 0) {
        v.push_back({i, j});
        v.push_back({j, i});
      } else if ((v.back()).first == i || (v.back()).second == j) {
        v.push_back({j, i});
        v.push_back({i, j});
      } else {
        v.push_back({i, j});
        v.push_back({j, i});
      }
      if (j == k) {
        i++;
        j = i + 1;
      } else
        j++;
    }
    for (long long i = 0; i < n; i++) {
      cout << v[i].first << " " << v[i].second << "\n";
    }
  }
  return 0;
}
void PT(long long a) { cout << a << "\n"; }
void PT1(long long a) { cout << a << " "; }
