#include <bits/stdc++.h>
inline int read() {
  int f = 1, x = 0;
  char ch = getchar();
  while (!(ch >= '0' && ch <= '9')) {
    if (ch == '-') f *= -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}
struct Blocks {
  int x, y, c;
} a[2000 * 2000 + 2], st, ed, ans[2][26];
bool cmp(Blocks p, Blocks q) {
  if (p.c != q.c)
    return p.c < q.c;
  else if (p.x != q.x)
    return p.x < q.x;
  else
    return p.y < q.y;
}
int t, n, m, len, cnt, pos, max;
char s[2000 + 1][2000 + 2], v[2000 + 1][2000 + 2];
bool check() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (s[i][j] != v[i][j]) return false;
  return true;
}
int main() {
  t = read();
  while (t--) {
    n = read(), m = read();
    len = max = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%s", s[i] + 1);
      for (int j = 1; j <= m; j++) {
        if (s[i][j] != '.') {
          len++;
          a[len].x = i, a[len].y = j, a[len].c = s[i][j] - 'a' + 1;
          max = std::max(max, a[len].c);
        }
      }
    }
    std::sort(a + 1, a + len + 1, cmp);
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) v[i][j] = '.';
      v[i][m + 1] = '\0';
    }
    st = a[1], a[len + 1].c = -1, cnt = 0;
    for (int i = 1; i <= len; i++) {
      if (a[i].c != a[i + 1].c) {
        ed = a[i];
        if (st.x == ed.x)
          for (int j = st.y; j <= ed.y; j++) v[st.x][j] = st.c + 'a' - 1;
        else
          for (int j = st.x; j <= ed.x; j++) v[j][st.y] = st.c + 'a' - 1;
        cnt++, ans[0][cnt] = st, ans[1][cnt] = ed;
        st = a[i + 1];
      }
    }
    if (check() == false)
      printf("NO\n");
    else {
      pos = 1;
      printf("YES\n%d\n", max);
      for (int i = 1; i <= cnt; i++) {
        for (int j = pos; j < ans[0][i].c; j++)
          printf("%d %d %d %d\n", ans[0][i].x, ans[0][i].y, ans[0][i].x,
                 ans[0][i].y);
        pos = ans[0][i].c + 1;
        printf("%d %d %d %d\n", ans[0][i].x, ans[0][i].y, ans[1][i].x,
               ans[1][i].y);
      }
    }
  }
}
