#include <bits/stdc++.h>
using namespace std;
void read(long long int n = 10) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(n) << fixed;
}
long long int M = 1e9 + 7;
long long int M1 = 998244353;
int32_t main() {
  read();
  long long int tcf;
  cin >> tcf;
  while (tcf--) {
    long long int n, m, sw = 0;
    cin >> n >> m;
    if (n < m) swap(n, m), sw = 1;
    if (n > 3 * m + 1) {
      cout << "NO\n";
      continue;
    }
    vector<pair<long long int, long long int> > arr;
    long long int i = 3;
    while (m--) {
      arr.push_back({2, i});
      i += 2;
    }
    long long int j = 2;
    while (j <= i - 1 && n) {
      arr.push_back({2, j});
      j += 2;
      n--;
    }
    j = 3;
    while (j <= i - 2 && n) {
      arr.push_back({1, j});
      j += 2;
      n--;
    }
    j = 3;
    while (j <= i - 2 && n) {
      arr.push_back({3, j});
      j += 2;
      n--;
    }
    cout << "YES\n";
    if (sw)
      for (long long int i = 0; i < arr.size(); i++)
        cout << arr[i].first << " " << arr[i].second << "\n";
    else
      for (long long int i = 0; i < arr.size(); i++)
        cout << arr[i].first + 1 << " " << arr[i].second << "\n";
  }
}
