#include namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; // returns (len_of_cycle, first_in-cycle_index) template std::pair detect_cycle(F f, S x) { S p = x, q = x; int l = 0; int ub = 1; do { if (l == ub) { ub <<= 1; l = 0; p = q; } q = f(q); l++; } while(p != q); p = q = x; for(int it = l; it > 0; it--) q = f(q); int m = 0; while(p != q) p = f(p), q = f(q), m++; return {l, m}; } } int main() { ios::sync_with_stdio(false); cin.tie(0); int h, w; ll k; cin >> h >> w >> k; struct S { int i, j, d; bool operator==(const S& rhs) const { return i == rhs.i && j == rhs.j && d == rhs.d; } bool operator!=(const S& rhs) const { return !(*this == rhs); } }; auto f = [&](S x) { auto [i, j, d] = x; int di = 1 - 2 * (d & 1); int ni = i + di; if (0 <= ni && ni < h) i = ni; else d ^= 1; int dj = 1 - (d & 2); int nj = j + dj; if (0 <= nj && nj < w) j = nj; else d ^= 2; return S{i, j, d}; }; S now{0, 0, 0}; auto [l, m] = detect_cycle(f, now); vector s(h, string(w, '.')); if (k >= m) { k = m + (k - m) % (2 * l); } rrep(_, k) { s[now.i][now.j] ^= '.' ^ '#'; now = f(now); } rep(i, h) cout << s[i] << '\n'; }