#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const int INF = 2147483647;
const long double PI = 3.1415926535898;
const long long oo = 9223372036854775807;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
template <class T>
T getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
T cntbit(T s) {
  return __builtin_popcountt(s);
}
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <typename T>
T Max(T a, T b) {
  return a > b ? a : b;
}
template <typename T>
T Min(T a, T b) {
  return a < b ? a : b;
}
template <typename T>
T abs(T a) {
  return a > 0 ? a : -a;
}
template <typename T>
long long pow(T a, T b) {
  long long res = 1;
  for (long long i = 1; i <= b; i++) res = res * a;
  return res;
}
template <class T>
void read(T &x) {
  x = 0;
  char c;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    ;
  x = c - '0';
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
}
template <class T>
void readchar(T &x) {
  for (x = getchar(); x != 'D' && x != 'C'; x = getchar())
    ;
}
template <typename T>
inline void writep(T x) {
  if (x > 9) writep(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  writep(x);
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
template <typename T>
inline void writec(T x) {
  write(x);
  putchar(' ');
}
long long n, k, a = 1, b = 2;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  if (n > k * (k - 1)) {
    cout << "NO";
    return 0;
  }
  cout << "YES\n";
  for (int i = 1; i <= n; i++) {
    cout << a << " " << b << '\n';
    if (a < b)
      swap(a, b);
    else {
      swap(a, b);
      if (b < k) {
        b++;
        if (b == a) b++;
      } else {
        a++;
        b = a + 1;
      }
    }
  }
}
