import sequtils, strutils proc printf(str: cstring) {.header: "", importc: "printf", varargs.} let n: int = stdin.readline.parseInt var a: seq[seq[int]] = newSeqWith(n, newSeq[int](n)) b: seq[seq[bool]] = newSeqWith(n, newSeq[bool](n)) x, y, tx, ty, cnt: int dx: array[4, int] = [1, 0, -1, 0] dy: array[4, int] = [0, 1, 0, -1] a[x][y] = 1 b[x][y] = true for i in 1..<(n * n): tx = x + dx[cnt and 3] ty = y + dy[cnt and 3] if tx < 0 or tx >= n or ty < 0 or ty >= n or b[tx][ty]: cnt.inc tx = x + dx[cnt and 3] ty = y + dy[cnt and 3] x = tx y = ty a[x][y] = i + 1 b[x][y] = true for j in 0..