#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int test;
  scanf("%d", &test);
  while (test--) {
    int n;
    scanf("%d", &n);
    int i;
    for (i = 0; i < n; i++) {
      char bane[50];
      int fuel;
      scanf("%s %d", bane, &fuel);
    }
    int m;
    scanf("%d", &m);
    int j;
    for (j = 0; j < m; j++) {
      char s1[50], s2[50];
      int fneed;
      scanf("%s %s %d", s1, s2, &fneed);
    }
    printf("Impossible\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecd(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     1208 <main+0xe8>
lea    0xea7(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a1 <main+0x81>
lea    -0x50(%rbp),%rsi
lea    0xe7b(%rip),%rdi
lea    -0x54(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1171 <main+0x51>
lea    0xe5e(%rip),%rdi
lea    -0x58(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x58(%rbp),%eax
jge    11f7 <main+0xd7>
lea    -0x90(%rbp),%rsi
lea    -0xd0(%rbp),%rdx
lea    0xe25(%rip),%rdi
lea    -0xd4(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11ba <main+0x9a>
lea    0xe0b(%rip),%rdi
call   1030 <printf@plt>
jmp    1144 <main+0x24>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
lea    0xece(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0x8(%rsp)
jae    115f <main+0x3f>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xea0(%rip),%rbp
lea    0x50(%rsp),%r13
lea    0x10(%rsp),%rbx
lea    0xe89(%rip),%r14
lea    0xc(%rsp),%r12
jmp    1193 <main+0x73>
xchg   %ax,%ax
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
subl   $0x1,0x8(%rsp)
jb     114b <main+0x2b>
mov    %rbp,%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
lea    0xe55(%rip),%r15
jle    11d9 <main+0xb9>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     11c0 <main+0xa0>
lea    0xe26(%rip),%rdi
mov    %rdi,%rbp
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,(%rsp)
jle    1180 <main+0x60>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%r15d
cmp    (%rsp),%r15d
jl     1200 <main+0xe0>
jmp    1180 <main+0x60>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%s %d\00"
@.str.2 = [9 x i8] c"%s %s %d\00"
@.str.3 = [12 x i8] c"Impossible\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [50 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [50 x i8]
%10 = alloca [50 x i8]
%11 = alloca i32
store i32 0, i32* %1
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %13
13: ; preds = %42, %0
%14 = load i32, i32* %2
%15 = add nsw i32 %14, -1
store i32 %15, i32* %2
%16 = icmp ne i32 %14, 0
br i1 %16, label %17, label %44
17: ; preds = %13
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 0, i32* %4
br label %19
19: ; preds = %26, %17
%20 = load i32, i32* %4
%21 = load i32, i32* %3
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %24, i32* %6)
br label %26
26: ; preds = %23
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %19
29: ; preds = %19
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
store i32 0, i32* %8
br label %31
31: ; preds = %39, %29
%32 = load i32, i32* %8
%33 = load i32, i32* %7
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %42
35: ; preds = %31
%36 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%37 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %36, i8* %37, i32* %11)
br label %39
39: ; preds = %35
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %31
42: ; preds = %31
%43 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %13
44: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%s %d\00"
@.str.2 = [9 x i8] c"%s %s %d\00"
@str = [11 x i8] c"Impossible\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [50 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca [50 x i8]
%7 = alloca [50 x i8]
%8 = alloca i32
%9 = bitcast i32* %1 to i8*
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = add nsw i32 %11, -1
store i32 %12, i32* %1
%13 = icmp eq i32 %11, 0
br i1 %13, label %47, label %14
14: ; preds = %0
%15 = bitcast i32* %2 to i8*
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%17 = bitcast i32* %4 to i8*
%18 = bitcast i32* %5 to i8*
%19 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%21 = bitcast i32* %8 to i8*
br label %22
22: ; preds = %14, %42
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%24 = load i32, i32* %2
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %22, %26
%27 = phi i32 [ %29, %26 ], [ 0, %22 ]
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32* %4)
%29 = add nuw nsw i32 %27, 1
%30 = load i32, i32* %2
%31 = icmp slt i32 %29, %30
br i1 %31, label %26, label %32
32: ; preds = %26, %22
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%34 = load i32, i32* %5
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %32, %36
%37 = phi i32 [ %39, %36 ], [ 0, %32 ]
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %19, i8* %20, i32* %8)
%39 = add nuw nsw i32 %37, 1
%40 = load i32, i32* %5
%41 = icmp slt i32 %39, %40
br i1 %41, label %36, label %42
42: ; preds = %36, %32
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%44 = load i32, i32* %1
%45 = add nsw i32 %44, -1
store i32 %45, i32* %1
%46 = icmp eq i32 %44, 0
br i1 %46, label %47, label %22
47: ; preds = %42, %0
ret i32 0
}