#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ flip(int, int, int *);
int /*<<< orphan*/ printAnswer(int, int, int *);
int /*<<< orphan*/ rotate(int *, int *, int *);
scalar_t__ scanf(char *, int *, ...);
int main() {
  int row = 0, col = 0, num = 0;
  int arr[100] = {0};
  int ops[10] = {0};
  while (scanf("%d %d %d", &row, &col, &num) != EOF) {
    for (int i = 0; i < row * col; ++i) {
      scanf("%d", &arr[i]);
    }
    for (int i = 0; i < num; ++i) {
      scanf("%d", &ops[i]);
    }
    while (num--) {
      int op = ops[num];
      if (op) {
        flip(row, col, arr);
      } else {
        rotate(&row, &col, arr);
      }
    }
    printAnswer(row, col, arr);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1030 <memset@plt>
lea    -0x1d0(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
lea    0xe5c(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    0x2e2a(%rip),%rcx
cmp    (%rcx),%rax
je     12eb <main+0x19b>
movl   $0x0,-0x1d4(%rbp)
mov    -0x1d4(%rbp),%eax
mov    -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    121d <main+0xcd>
movslq -0x1d4(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x1d4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1d4(%rbp)
jmp    11d1 <main+0x81>
movl   $0x0,-0x1d8(%rbp)
mov    -0x1d8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    126d <main+0x11d>
movslq -0x1d8(%rbp),%rax
lea    -0x1d0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x1d8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1d8(%rbp)
jmp    1227 <main+0xd7>
jmp    1272 <main+0x122>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x10(%rbp)
cmp    $0x0,%eax
je     12d4 <main+0x184>
movslq -0x10(%rbp),%rax
mov    -0x1d0(%rbp,%rax,4),%eax
mov    %eax,-0x1dc(%rbp)
cmpl   $0x0,-0x1dc(%rbp)
je     12bb <main+0x16b>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x1a0(%rbp),%rdx
call   1040 <flip@plt>
jmp    12cf <main+0x17f>
lea    -0x1a0(%rbp),%rdx
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <rotate@plt>
jmp    1272 <main+0x122>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x1a0(%rbp),%rdx
call   1070 <printAnswer@plt>
jmp    119d <main+0x4d>
xor    %eax,%eax
add    $0x1e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1d8,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0x40(%rsp),%r15
mov    $0x190,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
lea    0xe56(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x2e21(%rip),%rcx
cmp    (%rcx),%rax
jne    11e0 <main+0x90>
xor    %eax,%eax
add    $0x1d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe1f(%rip),%r12
lea    0xc(%rsp),%rbx
lea    0x8(%rsp),%r13
jmp    1235 <main+0xe5>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    %r15,%rdx
call   1070 <printAnswer@plt>
lea    0xde9(%rip),%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
lea    0x4(%rsp),%rcx
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x2db8(%rip),%rcx
cmp    (%rcx),%rax
je     11cc <main+0x7c>
mov    0x8(%rsp),%eax
imul   0xc(%rsp),%eax
test   %eax,%eax
jle    1278 <main+0x128>
mov    %r15,%r14
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rax
movslq 0x8(%rsp),%rcx
imul   %rax,%rcx
add    $0x4,%r14
cmp    %rcx,%rbp
jl     1250 <main+0x100>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    12d4 <main+0x184>
mov    %rbx,%r14
lea    0x10(%rsp),%rbp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
add    $0x4,%rbp
cmp    %rax,%rbx
jl     1290 <main+0x140>
mov    %r14,%rbx
jmp    12d4 <main+0x184>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    %r15,%rdx
call   1040 <flip@plt>
mov    0x4(%rsp),%eax
sub    $0x1,%eax
mov    %eax,0x4(%rsp)
jb     1200 <main+0xb0>
cltq
cmpl   $0x0,0x10(%rsp,%rax,4)
jne    12c0 <main+0x170>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1050 <rotate@plt>
mov    0x4(%rsp),%eax
jmp    12d4 <main+0x184>

LLVM IR (-O0):
@.str = [9 x i8] c"%d %d %d\00"
@EOF = global i64 0
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i32]
%6 = alloca [10 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%10 = bitcast [100 x i32]* %5 to i8*
%11 = bitcast [10 x i32]* %6 to i8*
br label %12
12: ; preds = %65, %0
%13 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%14 = load i64, i64* @EOF
%15 = icmp ne i64 %13, %14
br i1 %15, label %16, label %70
16: ; preds = %12
store i32 0, i32* %7
br label %17
17: ; preds = %28, %16
%18 = load i32, i32* %7
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = mul nsw i32 %19, %20
%22 = icmp slt i32 %18, %21
br i1 %22, label %23, label %31
23: ; preds = %17
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %25
%27 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %26)
br label %28
28: ; preds = %23
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %17
31: ; preds = %17
store i32 0, i32* %8
br label %32
32: ; preds = %41, %31
%33 = load i32, i32* %8
%34 = load i32, i32* %4
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %44
36: ; preds = %32
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %38
%40 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %39)
br label %41
41: ; preds = %36
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %32
44: ; preds = %32
br label %45
45: ; preds = %64, %44
%46 = load i32, i32* %4
%47 = add nsw i32 %46, -1
store i32 %47, i32* %4
%48 = icmp ne i32 %46, 0
br i1 %48, label %49, label %65
49: ; preds = %45
%50 = load i32, i32* %4
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %51
%53 = load i32, i32* %52
store i32 %53, i32* %9
%54 = load i32, i32* %9
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %61
56: ; preds = %49
%57 = load i32, i32* %2
%58 = load i32, i32* %3
%59 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 0
%60 = call i32 @flip(i32 %57, i32 %58, i32* %59)
br label %64
61: ; preds = %49
%62 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 0
%63 = call i32 @rotate(i32* %2, i32* %3, i32* %62)
br label %64
64: ; preds = %61, %56
br label %45
65: ; preds = %45
%66 = load i32, i32* %2
%67 = load i32, i32* %3
%68 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 0
%69 = call i32 @printAnswer(i32 %66, i32 %67, i32* %68)
br label %12
70: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d %d %d\00"
@EOF = global i64 0
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i32]
%5 = alloca [10 x i32]
%6 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%7 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%8 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%9 = bitcast [100 x i32]* %4 to i8*
%10 = bitcast [10 x i32]* %5 to i8*
%11 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%12 = load i64, i64* @EOF
%13 = icmp eq i64 %11, %12
br i1 %13, label %69, label %14
14: ; preds = %0
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
br label %16
16: ; preds = %14, %62
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = mul nsw i32 %18, %17
%20 = icmp sgt i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %24, %16
%22 = load i32, i32* %3
%23 = icmp sgt i32 %22, 0
br i1 %23, label %38, label %34
24: ; preds = %16, %24
%25 = phi i64 [ %28, %24 ], [ 0, %16 ]
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %25
%27 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %26)
%28 = add nuw nsw i64 %25, 1
%29 = load i32, i32* %1
%30 = load i32, i32* %2
%31 = mul nsw i32 %30, %29
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %28, %32
br i1 %33, label %24, label %21
34: ; preds = %38, %21
%35 = phi i32 [ %22, %21 ], [ %43, %38 ]
%36 = add nsw i32 %35, -1
store i32 %36, i32* %3
%37 = icmp eq i32 %35, 0
br i1 %37, label %62, label %46
38: ; preds = %21, %38
%39 = phi i64 [ %42, %38 ], [ 0, %21 ]
%40 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %39
%41 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %40)
%42 = add nuw nsw i64 %39, 1
%43 = load i32, i32* %3
%44 = sext i32 %43 to i64
%45 = icmp slt i64 %42, %44
br i1 %45, label %38, label %34
46: ; preds = %34, %58
%47 = phi i32 [ %60, %58 ], [ %36, %34 ]
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = icmp eq i32 %50, 0
br i1 %51, label %56, label %52
52: ; preds = %46
%53 = load i32, i32* %1
%54 = load i32, i32* %2
%55 = call i32 @flip(i32 %53, i32 %54, i32* %15)
br label %58
56: ; preds = %46
%57 = call i32 @rotate(i32* %1, i32* %2, i32* %15)
br label %58
58: ; preds = %56, %52
%59 = load i32, i32* %3
%60 = add nsw i32 %59, -1
store i32 %60, i32* %3
%61 = icmp eq i32 %59, 0
br i1 %61, label %62, label %46
62: ; preds = %58, %34
%63 = load i32, i32* %1
%64 = load i32, i32* %2
%65 = call i32 @printAnswer(i32 %63, i32 %64, i32* %15)
%66 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%67 = load i64, i64* @EOF
%68 = icmp eq i64 %66, %67
br i1 %68, label %69, label %16
69: ; preds = %62, %0
ret i32 0
}