#include <bits/stdc++.h>
int inp() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum;
}
std::vector<std::pair<int, int> > vec;
int main() {
  for (int T = inp(); T >= 1; T--) {
    vec.clear();
    int h = inp();
    int w = inp();
    int flg2 = 0;
    if (w < h) {
      flg2 = 1;
      std::swap(w, h);
    }
    int curx = 1;
    int cury = 3;
    while (w != h && h > 0) {
      if (w - h >= 2) {
        w -= 3;
        h--;
        vec.push_back(std::make_pair(curx, cury));
        vec.push_back(std::make_pair(curx + 1, cury - 1));
        vec.push_back(std::make_pair(curx + 1, cury + 1));
        vec.push_back(std::make_pair(curx + 1, cury));
        curx += 2;
      } else {
        vec.push_back(std::make_pair(curx, cury));
        vec.push_back(std::make_pair(curx, cury + 1));
        vec.push_back(std::make_pair(curx, cury + 2));
        curx++;
        cury++;
        w -= 2;
        h--;
      }
    }
    for (int i = 1; i <= h; i++) {
      vec.push_back(std::make_pair(curx, cury));
      vec.push_back(std::make_pair(curx + 1, cury));
      curx += 2;
    }
    int flg = 0;
    if (w != h && w - h > 1) {
      printf("NO\n");
      continue;
    }
    w -= h;
    h = 0;
    printf("YES\n");
    for (int i = 0; i < vec.size(); i++)
      printf("%d %d\n", vec[i].first + flg, vec[i].second + flg2);
    if (w - h > 0) printf("%d %d\n", curx + flg, cury + flg2);
  }
}
