fn main() { let mut nk = String::new(); std::io::stdin().read_line(&mut nk).ok(); let nk: Vec = nk.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nk[0]; let k = nk[1]; let mut result = 1usize; let mut cnt = 1usize; while cnt < n { result += 1; let rest = cnt % (k*k); cnt -= rest; let temp = result % k; cnt += if temp == 0 { k * k } else { temp * temp }; } println!("{}", result); let mut grid = vec![vec!["."; result]; result]; let mut cnt = 0usize; for i in 0..result { let start = i/k*k; for j in 0..k { if cnt == n { break; } if start+j >= result { break; } grid[i][start+j] = "#"; cnt += 1; } if cnt == n { break; } } for i in 0..result { println!("{}", grid[i].join("")); } }