#include <bits/stdc++.h>
using namespace std;
struct bi {
  int l, r, s, la, ra;
};
char a[2005][2005];
bi b[30];
bi c[30][2];
int main() {
  int tl;
  scanf("%d", &tl);
  while (tl--) {
    int n, m;
    int cnt = 0;
    memset(b, 0, sizeof(b));
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) scanf("%s", a[i]);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (a[i][j] != '.') {
          int ai = a[i][j] - 'a';
          if (!b[ai].s) {
            b[ai].la = i + 1;
            b[ai].ra = j + 1;
            cnt++;
            b[ai].l = i + 1;
            b[ai].r = j + 1;
          } else {
            b[ai].l = i + 1;
            b[ai].r = j + 1;
          }
          b[ai].s++;
        }
      }
    }
    int cap = 1;
    for (int i = 0; i < 26 && cap; i++) {
      int li = b[i].l, ri = b[i].r, lb = b[i].la, rb = b[i].ra;
      if (b[i].s) {
        if (li == lb && cap) {
          int t = 0;
          for (int j = rb; j <= ri; j++) {
            if (a[li - 1][j - 1] == i + 'a')
              t++;
            else if (a[li - 1][j - 1] < i + 'a' || a[li - 1][j - 1] == '.') {
              cap = 0;
              break;
            }
          }
          if (t != b[i].s) cap = 0;
        } else if (ri == rb && cap) {
          int t = 0;
          for (int j = lb; j <= li; j++) {
            if (a[j - 1][ri - 1] == i + 'a')
              t++;
            else if (a[j - 1][ri - 1] < i + 'a' || a[j - 1][ri - 1] == '.') {
              cap = 0;
              break;
            }
          }
          if (t != b[i].s) cap = 0;
        } else
          cap = 0;
      }
    }
    if (cap) {
      int po = -1;
      for (int i = 25; i >= 0; i--) {
        if (b[i].s) {
          po = i;
        } else if (po != -1) {
          b[i].l = b[po].l;
          b[i].la = b[po].la;
          b[i].r = b[po].r;
          b[i].ra = b[po].ra;
          b[i].s = b[po].s;
          cnt++;
        }
      }
      printf("YES\n");
      printf("%d\n", cnt);
      for (int i = 0; i < 26; i++) {
        if (b[i].s) {
          printf("%d %d %d %d\n", b[i].la, b[i].ra, b[i].l, b[i].r);
        }
      }
    } else
      printf("NO\n");
  }
  return 0;
}
