#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m, a, b;
  cin >> n >> m >> a >> b;
  if (n * a == m * b) {
    cout << "YES"
         << "\n";
    int matrix[n][m];
    for (register int i = 0; i < n; i++)
      for (register int j = 0; j < m; j++) matrix[i][j] = 0;
    int j = 0;
    for (register int i = 0; i < n; i++) {
      int k = 0;
      while (k < a) {
        matrix[i][j % m] = 1;
        j++;
        k++;
      }
    }
    for (register int i = 0; i < n; i++) {
      for (register int j = 0; j < m; j++) {
        cout << matrix[i][j];
      }
      cout << endl;
    }
  } else
    cout << "NO"
         << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  ;
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
