#include <bits/stdc++.h>
const char dl = '\n';
const long double eps = 0.00000001;
const long long MOD = 1e9 + 7;
const long long mod = 998244353;
const double PI = 3.141592653589793238463;
const long double pi = 4 * atan(1.0);
using namespace std;
void debug() { cout << endl; }
template <typename H, typename... T>
void debug(H p, T... t) {
  std::cout << p << " ";
  debug(t...);
}
string second, t;
long long n, m, k;
stack<char> STACK;
deque<char> DEQUE;
queue<char> QUEUE;
set<pair<int, int>> have;
vector<pair<int, int>> ans;
map<int, set<int>> man;
int main() {
  fflush(stdin);
  cout << fixed, cout.precision(18);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, j;
  cin >> n >> k;
  if (n > (k * 1ll * (k - 1))) return cout << "NO", 0;
  int m = 1, g = 2, cyc = 2;
  cout << "YES" << endl;
  for (i = 0; i < n; ++i) {
    if (m > k) m %= k, g = ++cyc;
    if (g > k) g %= k;
    cout << m++ << " " << g++ << endl;
  }
}
