local w, h, x = io.read("*n", "*n", "*n") if x == 0 then for i = 1, h do print(string.rep("0", w)) end os.exit() end if w == 1 then if h == 1 then if 9 < x then print(-1) else print(x) end elseif h % 3 ~= 2 or 18 < x then print(-1) else local t = {} t[1] = math.min(x, 9) t[2] = x - t[1] for i = 1, h do if i % 3 == 1 then print(t[1]) elseif i % 3 == 2 then print(t[2]) else print(0) end end end os.exit() end if h == 1 then if w % 3 ~= 2 or 18 < x then print(-1) else local t = {} t[1] = math.min(x, 9) t[2] = x - t[1] for j = 1, w do if j % 3 == 1 then io.write(t[1]) elseif j % 3 == 2 then io.write(t[2]) else io.write(0) end end io.write("\n") end os.exit() end if 36 < x then print(-1) os.exit() end local rx = x local t = {} for i = 1, 4 do t[i] = math.min(x, 9) x = x - t[i] end x = rx if 18 < x then if w % 3 ~= 2 or h % 3 ~= 2 then print(-1) os.exit() end for i = 1, h do for j = 1, w do if i % 3 == 1 and j % 3 == 1 then io.write(t[1]) elseif i % 3 == 1 and j % 3 == 2 then io.write(t[2]) elseif i % 3 == 2 and j % 3 == 1 then io.write(t[3]) elseif i % 3 == 2 and j % 3 == 2 then io.write(t[4]) else io.write(0) end end io.write("\n") end os.exit() end if 9 < x then if w % 3 ~= 2 and h % 3 ~= 2 then print(-1) os.exit() end if w % 3 == 2 then if h % 3 == 0 then t[1], t[3] = t[3], t[1] t[2], t[4] = t[4], t[2] end else if w % 3 == 0 then t[1], t[2] = t[2], t[1] t[3], t[4] = t[4], t[3] end end for i = 1, h do for j = 1, w do if i % 3 == 1 and j % 3 == 1 then io.write(t[1]) elseif i % 3 == 1 and j % 3 == 2 then io.write(t[2]) elseif i % 3 == 2 and j % 3 == 1 then io.write(t[3]) elseif i % 3 == 2 and j % 3 == 2 then io.write(t[4]) else io.write(0) end end io.write("\n") end os.exit() end do if w % 3 == 0 then if h % 3 == 0 then t[1], t[4] = t[4], t[1] else t[1], t[2] = t[2], t[1] end elseif w % 3 == 1 then if h % 3 == 0 then t[1], t[3] = t[3], t[1] end else if h % 3 == 0 then t[1], t[3] = t[3], t[1] end end for i = 1, h do for j = 1, w do if i % 3 == 1 and j % 3 == 1 then io.write(t[1]) elseif i % 3 == 1 and j % 3 == 2 then io.write(t[2]) elseif i % 3 == 2 and j % 3 == 1 then io.write(t[3]) elseif i % 3 == 2 and j % 3 == 2 then io.write(t[4]) else io.write(0) end end io.write("\n") end os.exit() end