package main
import "fmt"
func main() {
var n, r, c int
fmt.Scanf("%d", &n)
code := make([]string, n)
for i := 0; i < n; i++ {
var s string
fmt.Scanf("%s", &s)
code[i] = s[1:] + s[:1]
}
s := []int{2, 4, 8, 16, 32, 64, 128}
fmt.Scanf("%d %d", &r, &c)
d := r
if r < c {
d = c
}
for i := 0; i < 7; i++ {
if d <= s[i] {
d = s[i]
break
}
}
grid := make([][]int, d)
for i := 0; i < d; i++ {
grid[i] = make([]int, d)
for j := 0; j < d; j++ {
grid[i][j] = 0
}
}
quadtree(grid, 0, 0, d, code)
// TODO: Change to r and c
for i := 0; i < d; i++ {
for j := 0; j < d; j++ {
if j > 0 {
fmt.Print(" ")
}
fmt.Print(grid[i][j])
}
fmt.Println()
}
}
func quadtree(grid [][]int, r, c, d int, code []string) {
if len(code) == 1 && len(code[0]) == 1 {
if code[0][0] == '1' {
for i := r; i < r+d; i++ {
for j := c; j < c+d; j++ {
grid[i][j] = 1
}
}
}
return
}
_code := make([][]string, 4)
for i := 0; i < 4; i++ {
_code[i] = []string{}
}
for i := 0; i < len(code); i++ {
q := []rune(code[i])[0]-'0'
_code[q] = append(_code[q], code[i][1:])
}
_d := d>>1
for i := 0; i < 4; i++ {
if len(_code[i]) > 0 {
_r := r + (i>>1)*_d
_c := c + (i&1)*_d
quadtree(grid, _r, _c, _d, _code[i])
}
}
}
cGFja2FnZSBtYWluCgppbXBvcnQgImZtdCIKCmZ1bmMgbWFpbigpIHsKICB2YXIgbiwgciwgYyBpbnQKICBmbXQuU2NhbmYoIiVkIiwgJm4pCiAgCiAgY29kZSA6PSBtYWtlKFtdc3RyaW5nLCBuKQogIGZvciBpIDo9IDA7IGkgPCBuOyBpKysgewogICAgdmFyIHMgc3RyaW5nCiAgICBmbXQuU2NhbmYoIiVzIiwgJnMpCiAgICBjb2RlW2ldID0gc1sxOl0gKyBzWzoxXQogIH0KICAKICBzIDo9IFtdaW50ezIsIDQsIDgsIDE2LCAzMiwgNjQsIDEyOH0KICBmbXQuU2NhbmYoIiVkICVkIiwgJnIsICZjKQogIAogIGQgOj0gcgogIGlmIHIgPCBjIHsKICAgIGQgPSBjCiAgfQogIGZvciBpIDo9IDA7IGkgPCA3OyBpKysgewogICAgaWYgZCA8PSBzW2ldIHsKICAgICAgZCA9IHNbaV0KICAgICAgYnJlYWsKICAgIH0KICB9CiAgIAogIGdyaWQgOj0gbWFrZShbXVtdaW50LCBkKQogIGZvciBpIDo9IDA7IGkgPCBkOyBpKysgewogICAgZ3JpZFtpXSA9IG1ha2UoW11pbnQsIGQpCiAgICBmb3IgaiA6PSAwOyBqIDwgZDsgaisrIHsKICAgICAgZ3JpZFtpXVtqXSA9IDAKICAgIH0KICB9CiAgCiAgcXVhZHRyZWUoZ3JpZCwgMCwgMCwgZCwgY29kZSkKICAKICAvLyBUT0RPOiBDaGFuZ2UgdG8gciBhbmQgYwogIGZvciBpIDo9IDA7IGkgPCBkOyBpKysgewogICAgZm9yIGogOj0gMDsgaiA8IGQ7IGorKyB7CiAgICAgIGlmIGogPiAwIHsKICAgICAgICBmbXQuUHJpbnQoIiAiKQogICAgICB9CiAgICAgIGZtdC5QcmludChncmlkW2ldW2pdKQogICAgfQogICAgZm10LlByaW50bG4oKQogIH0KfQoKZnVuYyBxdWFkdHJlZShncmlkIFtdW11pbnQsIHIsIGMsIGQgaW50LCBjb2RlIFtdc3RyaW5nKSB7CiAgaWYgbGVuKGNvZGUpID09IDEgJiYgbGVuKGNvZGVbMF0pID09IDEgewogICAgaWYgY29kZVswXVswXSA9PSAnMScgewogICAgICBmb3IgaSA6PSByOyBpIDwgcitkOyBpKysgewogICAgICAgIGZvciBqIDo9IGM7IGogPCBjK2Q7IGorKyB7CiAgICAgICAgICBncmlkW2ldW2pdID0gMQogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuCiAgfQogIAogIF9jb2RlIDo9IG1ha2UoW11bXXN0cmluZywgNCkKICBmb3IgaSA6PSAwOyBpIDwgNDsgaSsrIHsKICAgIF9jb2RlW2ldID0gW11zdHJpbmd7fQogIH0KICBmb3IgaSA6PSAwOyBpIDwgbGVuKGNvZGUpOyBpKysgewogICAgcSA6PSBbXXJ1bmUoY29kZVtpXSlbMF0tJzAnCiAgICBfY29kZVtxXSA9IGFwcGVuZChfY29kZVtxXSwgY29kZVtpXVsxOl0pCiAgfQogIAogIF9kIDo9IGQ+PjEKICBmb3IgaSA6PSAwOyBpIDwgNDsgaSsrIHsKICAgIGlmIGxlbihfY29kZVtpXSkgPiAwIHsKICAgICAgX3IgOj0gciArIChpPj4xKSpfZAogICAgICBfYyA6PSBjICsgKGkmMSkqX2QKICAgICAgcXVhZHRyZWUoZ3JpZCwgX3IsIF9jLCBfZCwgX2NvZGVbaV0pCiAgICB9CiAgfQp9