#include using namespace std; bool possible(int h, int w, int k) { if (k == 0) { return true; } if (h == 1 || w == 1) { return k == 1; } int maximum = h * w - h - w + 2; return 2 <= k && k <= maximum; } vector transposeGrid(const vector& grid) { int h = static_cast(grid.size()); int w = static_cast(grid[0].size()); vector result(w, string(h, '.')); for (int row = 0; row < h; row++) { for (int col = 0; col < w; col++) { result[col][row] = grid[row][col]; } } return result; } vector buildOriented(int h, int w, int k) { vector grid(h, string(w, '.')); if (k == 0) { return vector(h, string(w, '#')); } if (h == 1) { grid[0][0] = '#'; return grid; } if (k <= w) { for (int col = 0; col < k - 1; col++) { grid[0][col] = '#'; } return grid; } int x = k - w; vector columns; for (int col = 0; col < w; col += 2) { columns.push_back(col); } int toothCount = static_cast(columns.size()); int maxExtension = h - 2; int oneCapacity = 0; vector oneIndices; vector twoIndices; for (int index = 0; index < toothCount; index++) { int col = columns[index]; if (col == 0 || col == w - 1) { oneCapacity += maxExtension; oneIndices.push_back(index); } else { twoIndices.push_back(index); } } int twoCapacity = 2 * maxExtension * static_cast(twoIndices.size()); int lower = max(0, x - twoCapacity); int upper = min(oneCapacity, x); int ones = -1; for (int value = lower; value <= upper; value++) { if (value % 2 == x % 2) { ones = value; break; } } vector lengths(toothCount, 1); int remainingOnes = ones; for (int index : oneIndices) { int take = min(maxExtension, remainingOnes); lengths[index] += take; remainingOnes -= take; } int remainingTwos = (x - ones) / 2; for (int index : twoIndices) { int take = min(maxExtension, remainingTwos); lengths[index] += take; remainingTwos -= take; } int lastColumn = columns.back(); for (int col = 0; col <= lastColumn; col++) { grid[0][col] = '#'; } for (int index = 0; index < toothCount; index++) { int col = columns[index]; for (int row = 0; row < lengths[index]; row++) { grid[row][col] = '#'; } } return grid; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int h; int w; int k; cin >> h >> w >> k; if (!possible(h, w, k)) { cout << -1 << '\n'; return 0; } vector answer; if (h == 1 || w == 1) { if (h == 1) { answer = buildOriented(h, w, k); } else { answer = transposeGrid(buildOriented(w, h, k)); } } else if (w >= h) { answer = buildOriented(h, w, k); } else { answer = transposeGrid(buildOriented(w, h, k)); } for (const string& row : answer) { cout << row << '\n'; } return 0; }