package main import ( "bufio" "fmt" "os" ) func main() { var N int fmt.Scan(&N) // time0 := time.Now() // defer func() { fmt.Fprintln(os.Stderr, time.Since(time0)) }() wr := bufio.NewWriter(os.Stdout) for i := 0; i < N; i++ { for j := 0; j < N; j++ { if j > 0 { fmt.Fprint(wr, " ") } fmt.Fprint(wr, 1+(i+j)%N) } fmt.Fprintln(wr) } }