#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> ans;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  if (k * (k - 1) < n) {
    cout << "NO" << endl;
    return 0;
  }
  long long cnt = 0;
  for (long long j = 1; j < k; j++) {
    for (long long i = 1; i <= k - j; i++) {
      if (i == 1 && k == i + j) {
        continue;
      }
      cnt++;
      ans.push_back({i, i + j});
      if (cnt == n) {
        cout << "YES" << endl;
        for (auto z : ans) {
          cout << z.first << " " << z.second << endl;
        }
        return 0;
      }
    }
  }
  for (long long j = 1; j < k; j++) {
    for (long long i = j + 1; i <= k; i++) {
      if (i == k && i - j == 1) continue;
      if (i == 2 && i - j == 1) {
        continue;
      }
      cnt++;
      ans.push_back({i, i - j});
      if (cnt == n) {
        cout << "YES" << endl;
        for (auto z : ans) {
          cout << z.first << " " << z.second << endl;
        }
        return 0;
      }
    }
  }
  if (cnt < n) {
    cnt++;
  }
  if (cnt == n) {
    cout << "YES" << endl;
    cout << k << " " << 1 << endl;
    for (auto z : ans) {
      cout << z.first << " " << z.second << endl;
    }
    return 0;
  }
  if (cnt < n) {
    cnt++;
  }
  if (cnt == n) {
    cout << "YES" << endl;
    cout << 1 << " " << k << endl;
    cout << k << " " << 1 << endl;
    for (auto z : ans) {
      cout << z.first << " " << z.second << endl;
    }
  } else {
    cout << "YES" << endl;
    cout << 2 << " " << 1 << endl;
    cout << 1 << " " << k << endl;
    cout << k << " " << 1 << endl;
    for (auto z : ans) {
      cout << z.first << " " << z.second << endl;
    }
  }
  return 0;
}
