#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b, t;
  cin >> t;
  while (t--) {
    cin >> n >> m >> a >> b;
    int x[55][55] = {0};
    if (n * a != m * b or a > m or b > n)
      cout << "NO\n";
    else {
      int j = 0;
      cout << "YES\n";
      for (int i = 0; i < n; i++) {
        int cnt = 0;
        while (cnt < a) {
          x[i][j] = 1;
          j = (j + 1) % m;
          cnt++;
        }
      }
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) cout << x[i][j];
        cout << "\n";
      }
    }
  }
}
