#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200002;
long long n, m, sum, x, y, sz, cnt, ans, mx;
long long a[MAXN];
vector<vector<int> > v;
vector<int> g;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  if (n > (m * (m - 1)))
    cout << "NO";
  else {
    cout << "YES\n";
    bool ok = 0;
    for (int i = 1; i <= m && !ok; ++i) {
      for (int j = i + 1; j <= m; ++j) {
        ++ans;
        if (ans > n) {
          ok = 1;
          break;
        }
        cout << i << " " << j << "\n";
        ++ans;
        if (ans > n) {
          ok = 1;
          break;
        }
        cout << j << " " << i << "\n";
      }
    }
  }
}
