#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 */
int /*<<< orphan*/ computeAllPairShortestPath(int **, int);
int /*<<< orphan*/ memset(int **, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *, ...);
int main(void) {
  int caseId, adjMat[20][20], numNeighbor, neighbor, stopFlg, city, time,
      numQuery, cityOne, cityTwo, query;
  caseId = 1;
  stopFlg = 0;
  while (1) {
    memset(adjMat, 0, 20 * 20 * sizeof(int));
    for (city = 0; city < 20 - 1; city++)
      if (scanf("%d", &numNeighbor) > 0) {
        for (time = 0; time < numNeighbor; time++) {
          scanf("%d", &neighbor);
          neighbor--;
          adjMat[neighbor][city] = 1;
          adjMat[city][neighbor] = 1;
        }
      } else {
        stopFlg = 1;
        break;
      }
    if (stopFlg)
      break;
    computeAllPairShortestPath(adjMat, 20);
    printf("Test Set #%d\n", caseId);
    scanf("%d", &numQuery);
    for (query = 0; query < numQuery; query++) {
      scanf("%d %d", &cityOne, &cityTwo);
      printf("%2d to %2d: %d\n", cityOne, cityTwo,
             adjMat[cityOne - 1][cityTwo - 1]);
    }
    printf("\n");
    caseId++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x680,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0x65c(%rbp)
lea    -0x650(%rbp),%rdi
xor    %esi,%esi
mov    $0x640,%edx
call   1040 <memset@plt>
movl   $0x0,-0x660(%rbp)
cmpl   $0x13,-0x660(%rbp)
jge    1273 <main+0x133>
lea    0xe7d(%rip),%rdi
lea    -0x654(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
cmp    $0x0,%rax
jle    124b <main+0x10b>
movl   $0x0,-0x664(%rbp)
mov    -0x664(%rbp),%eax
cmp    -0x654(%rbp),%eax
jge    1246 <main+0x106>
lea    0xe42(%rip),%rdi
lea    -0x658(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x658(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x658(%rbp)
movslq -0x658(%rbp),%rcx
lea    -0x650(%rbp),%rax
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
movslq -0x660(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
movslq -0x660(%rbp),%rcx
lea    -0x650(%rbp),%rax
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
movslq -0x658(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x664(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x664(%rbp)
jmp    11b6 <main+0x76>
jmp    125a <main+0x11a>
movl   $0x1,-0x65c(%rbp)
jmp    1273 <main+0x133>
jmp    125f <main+0x11f>
mov    -0x660(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x660(%rbp)
jmp    1180 <main+0x40>
cmpl   $0x0,-0x65c(%rbp)
je     1285 <main+0x145>
jmp    1367 <main+0x227>
lea    -0x650(%rbp),%rdi
mov    $0x14,%esi
call   1050 <computeAllPairShortestPath@plt>
mov    -0x8(%rbp),%esi
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd63(%rip),%rdi
lea    -0x668(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x0,-0x674(%rbp)
mov    -0x674(%rbp),%eax
cmp    -0x668(%rbp),%eax
jge    134b <main+0x20b>
lea    0xd2f(%rip),%rdi
lea    -0x66c(%rbp),%rsi
lea    -0x670(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x66c(%rbp),%esi
mov    -0x670(%rbp),%edx
mov    -0x66c(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    -0x650(%rbp),%rax
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
mov    -0x670(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xce4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x674(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x674(%rbp)
jmp    12c6 <main+0x186>
lea    0xcd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1163 <main+0x23>
xor    %eax,%eax
add    $0x680,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x668,%rsp
movl   $0x1,0x8(%rsp)
lea    0x20(%rsp),%rdi
lea    0xe9c(%rip),%rbp
lea    0x10(%rsp),%r14
lea    0xe8d(%rip),%rbx
lea    0x1c(%rsp),%r12
xor    %esi,%esi
mov    $0x640,%edx
call   1050 <memset@plt>
xor    %r13d,%r13d
jmp    11b1 <main+0x61>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    $0x13,%r13
mov    %r15,%rbx
je     1240 <main+0xf0>
mov    %rbp,%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
test   %rax,%rax
jle    12dc <main+0x18c>
mov    %rbx,%r15
cmpl   $0x0,0x14(%rsp)
jle    11a0 <main+0x50>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movslq 0x10(%rsp),%rax
lea    -0x1(%rax),%rcx
mov    %ecx,0x10(%rsp)
lea    (%rcx,%rcx,4),%rcx
shl    $0x4,%rcx
add    %rsp,%rcx
add    $0x20,%rcx
movl   $0x1,(%rcx,%r13,4)
lea    0x0(,%r13,4),%rcx
add    %r13,%rcx
shl    $0x4,%rcx
add    %rsp,%rcx
add    $0x20,%rcx
movl   $0x1,-0x4(%rcx,%rax,4)
add    $0x1,%ebx
cmp    0x14(%rsp),%ebx
jl     11e0 <main+0x90>
jmp    11a0 <main+0x50>
nopl   (%rax)
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    $0x14,%esi
call   1060 <computeAllPairShortestPath@plt>
lea    0xda7(%rip),%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
mov    %rbx,%r13
jle    12c2 <main+0x172>
xor    %ebx,%ebx
nop
mov    %r13,%rdi
mov    %r12,%rsi
lea    0x18(%rsp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
movslq 0x1c(%rsp),%rsi
movslq 0x18(%rsp),%rdx
lea    (%rsi,%rsi,4),%rax
shl    $0x4,%rax
add    %r15,%rax
mov    -0x54(%rax,%rdx,4),%ecx
lea    0xd62(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    0xc(%rsp),%ebx
jl     1280 <main+0x130>
mov    $0xa,%edi
call   1030 <putchar@plt>
addl   $0x1,0x8(%rsp)
mov    %r13,%rbx
mov    %r15,%rdi
jmp    1186 <main+0x36>
xor    %eax,%eax
add    $0x668,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [14 x i8] c"Test Set #%d\0A\00"
@.str.2 = [6 x i8] c"%d %d\00"
@.str.3 = [16 x i8] c"%2d to %2d: %d\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [20 x [20 x i32]]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 0, i32* %6
br label %13
13: ; preds = %0, %85
%14 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* %3, i64 0, i64 0
%15 = bitcast [20 x i32]* %14 to i32**
%16 = call i32 @memset(i32** %15, i32 0, i32 1600)
store i32 0, i32* %7
br label %17
17: ; preds = %50, %13
%18 = load i32, i32* %7
%19 = icmp slt i32 %18, 19
br i1 %19, label %20, label %53
20: ; preds = %17
%21 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%22 = icmp sgt i64 %21, 0
br i1 %22, label %23, label %48
23: ; preds = %20
store i32 0, i32* %8
br label %24
24: ; preds = %44, %23
%25 = load i32, i32* %8
%26 = load i32, i32* %4
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %47
28: ; preds = %24
%29 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%30 = load i32, i32* %5
%31 = add nsw i32 %30, -1
store i32 %31, i32* %5
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* %3, i64 0, i64 %33
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [20 x i32], [20 x i32]* %34, i64 0, i64 %36
store i32 1, i32* %37
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* %3, i64 0, i64 %39
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [20 x i32], [20 x i32]* %40, i64 0, i64 %42
store i32 1, i32* %43
br label %44
44: ; preds = %28
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %24
47: ; preds = %24
br label %49
48: ; preds = %20
store i32 1, i32* %6
br label %53
49: ; preds = %47
br label %50
50: ; preds = %49
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %17
53: ; preds = %48, %17
%54 = load i32, i32* %6
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %53
br label %89
57: ; preds = %53
%58 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* %3, i64 0, i64 0
%59 = bitcast [20 x i32]* %58 to i32**
%60 = call i32 @computeAllPairShortestPath(i32** %59, i32 20)
%61 = load i32, i32* %2
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %61)
%63 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
store i32 0, i32* %12
br label %64
64: ; preds = %82, %57
%65 = load i32, i32* %12
%66 = load i32, i32* %9
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %85
68: ; preds = %64
%69 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %10, i32* %11)
%70 = load i32, i32* %10
%71 = load i32, i32* %11
%72 = load i32, i32* %10
%73 = sub nsw i32 %72, 1
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [20 x [20 x i32]], [20 x [20 x i32]]* %3, i64 0, i64 %74
%76 = load i32, i32* %11
%77 = sub nsw i32 %76, 1
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [20 x i32], [20 x i32]* %75, i64 0, i64 %78
%80 = load i32, i32* %79
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %70, i32 %71, i32 %80)
br label %82
82: ; preds = %68
%83 = load i32, i32* %12
%84 = add nsw i32 %83, 1
store i32 %84, i32* %12
br label %64
85: ; preds = %64
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%87 = load i32, i32* %2
%88 = add nsw i32 %87, 1
store i32 %88, i32* %2
br label %13
89: ; preds = %56
ret i32 0
}

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