package main import ( "bufio" "fmt" "os" "strconv" ) func configure(scanner *bufio.Scanner) { scanner.Split(bufio.ScanWords) scanner.Buffer(make([]byte, 1000005), 1000005) } func getNextString(scanner *bufio.Scanner) string { scanned := scanner.Scan() if !scanned { panic("scan failed") } return scanner.Text() } func getNextInt(scanner *bufio.Scanner) int { i, _ := strconv.Atoi(getNextString(scanner)) return i } func getNextInt64(scanner *bufio.Scanner) int64 { i, _ := strconv.ParseInt(getNextString(scanner), 10, 64) return i } func getNextFloat64(scanner *bufio.Scanner) float64 { i, _ := strconv.ParseFloat(getNextString(scanner), 64) return i } func main() { fp := os.Stdin wfp := os.Stdout extra := 0 if os.Getenv("I") == "IronMan" { fp, _ = os.Open(os.Getenv("END_GAME")) extra = 100 } scanner := bufio.NewScanner(fp) configure(scanner) writer := bufio.NewWriter(wfp) defer func() { r := recover() if r != nil { fmt.Fprintln(writer, r) } writer.Flush() }() solve(scanner, writer) for i := 0; i < extra; i++ { fmt.Fprintln(writer, "-----------------------------------") solve(scanner, writer) } } func solve(scanner *bufio.Scanner, writer *bufio.Writer) { r := getNextInt(scanner) k := getNextInt(scanner) h := getNextInt(scanner) w := getNextInt(scanner) g := makeGrid(h*k, w*k) for i := 0; i < h; i++ { s := getNextString(scanner) for j := 0; j < w; j++ { for ii := 0; ii < k; ii++ { for jj := 0; jj < k; jj++ { g[i*k+ii][j*k+jj] = s[j] } } } } switch r { case 0: for i := 0; i < h*k; i++ { for j := 0; j < w*k; j++ { fmt.Fprint(writer, fmt.Sprintf("%c", g[i][j])) } fmt.Fprintln(writer, "") } case 90: for j := 0; j < w*k; j++ { for i := h*k - 1; i >= 0; i-- { fmt.Fprint(writer, fmt.Sprintf("%c", g[i][j])) } fmt.Fprintln(writer, "") } case 180: for i := h*k - 1; i >= 0; i-- { for j := w*k - 1; j >= 0; j-- { fmt.Fprint(writer, fmt.Sprintf("%c", g[i][j])) } fmt.Fprintln(writer, "") } case 270: for j := w*k - 1; j >= 0; j-- { for i := 0; i < h*k; i++ { fmt.Fprint(writer, fmt.Sprintf("%c", g[i][j])) } fmt.Fprintln(writer, "") } } } func makeGrid(h, w int) [][]byte { index := make([][]byte, h, h) data := make([]byte, h*w, h*w) for i := 0; i < h; i++ { index[i] = data[i*w : (i+1)*w] } return index }