#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector> a(3); for(int i = 0; i < 3; i++){ cin >> a[i].second; a[i].first = '1' + i; } vector A(n, string(n, '?')); vector> dir = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; auto dfs = [&](auto dfs, int y, int x, int cur) -> bool { if(cur == -1) return true; for(auto [dy, dx] : dir){ int ny = y + dy, nx = x + dx; if(ny < 0 || nx < 0 || ny >= n || nx >= n) continue; if(A[ny][nx] == cur + '1' && dfs(dfs, ny, nx, cur - 1)) return true; } return false; }; do{ auto b = a; for(int y = 0; y < n; y++){ for(int x = 0; x < n; x++){ for(int i = 0; i < 3; i++){ if(b[i].second >= 1){ b[i].second--; A[y][x] = b[i].first; break; } } } } bool flg = true; for(int y = 0; y < n && flg; y++){ for(int x = 0; x < n; x++){ if(A[y][x] == '3' && dfs(dfs, y, x, 1)){ flg = false; break; } } } if(flg){ for(auto &&str : A) cout << str << '\n'; return 0; } }while(next_permutation(a.begin(), a.end())); }