#include using namespace std; const int N = 110; int main() { int T; cin >> T; while (T--) { int res = 0; int n, m; int a[N][N]; cin >> n >> m; for (int i = 1; i <= n; i++) { string s; cin >> s; for (int j = 1; j <= m; j++) { a[i][j] = s[j - 1] - '0'; } } // for (int i = 1; i <= n;i++){ // for (int j = 1; j <= m;j++){ // cout << a[i][j] << " "; // } // cout << endl; // } for (int i = 1; i + 3 <= n; i++) { for (int j = 1; j + 3 <= m; j++) { int cnt = 0; if (a[i][j] == 0 && a[i + 1][j] == 0 && a[i + 2][j] == 0 && a[i + 3][j] == 0) { cnt++; } if (a[i + 3][j] == 0 && a[i + 3][j + 1] == 0 && a[i + 3][j + 2] == 0 && a[i + 3][j + 3] == 0) { cnt++; } if (a[i + 1][j] == 0 && a[i + 1][j + 1] == 1 && a[i + 1][j + 2] == 1 && a[i + 1][j + 3] == 0) { cnt++; } if (a[i + 2][j] == 0 && a[i + 2][j + 1] == 1 && a[i + 2][j + 2] == 1 && a[i + 2][j + 3] == 0) { cnt++; } if (cnt == 4) { res++; } } } if (res == 0) cout << "No" << endl; else cout << "Yes" << endl; } return 0; }