h, w = read_line.split.map(&.to_i) k = read_line.to_i64 k %= (h * w * 4) y = 0 x = 0 dy = 1 dx = 1 ans = Array.new(h) { Array.new(w, false) } k.times do ans[y][x] = !ans[y][x] if y + dy < 0 || h <= y + dy dy *= -1 else y += dy end if x + dx < 0 || w <= x + dx dx *= -1 else x += dx end end h.times do |i| puts w.times.map { |j| ans[i][j] ? '#' : '.' }.join end def move(l, k) ret = Array.new(l, false) len = k % (l * 2) if len < k len.times { |i| ret[i] = true } else ret.fill(true) (len - k).times { |i| ret[l - 1 - i] = false } end return ret end