#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*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sscanf(char *, char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ *strstr(char *, char *);
int main(int argc, char **argv) {
  int BUFFSIZE = 200000;
  char buffer[BUFFSIZE];
  int rc;
  if (fgets(buffer, BUFFSIZE, stdin) == NULL) {
    printf("Failure to read k from stdin\n");
    return 0;
  }
  int k, i;
  sscanf(buffer, "%d", &k);
  for (i = 0; i < k; i++) {
    if (fgets(buffer, BUFFSIZE, stdin) == NULL) {
      printf("Failure to read S from stdin\n");
      return 0;
    }
    char S[200000];
    sscanf(buffer, "%s", S);
    if (fgets(buffer, BUFFSIZE, stdin) == NULL) {
      printf("Failure to get number of query strings\n");
      return 0;
    }
    int q, j;
    sscanf(buffer, "%d", &q);
    for (j = 0; j < q; j++) {
      if (fgets(buffer, BUFFSIZE, stdin) == NULL) {
        printf("Failure to read T from stdin\n");
        return 0;
      }
      char T[2000];
      sscanf(buffer, "%s", T);
      if (strstr(S, T) != NULL) {
        printf("y\n");
      } else {
        printf("n\n");
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x31570,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x30d40,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x31568(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
mov    0x2e55(%rip),%rax
mov    (%rax),%edx
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    11c3 <main+0x83>
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    1396 <main+0x256>
mov    -0x31568(%rbp),%rdi
lea    0xe4d(%rip),%rsi
lea    -0x34(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1388 <main+0x248>
mov    -0x31568(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2de8(%rip),%rax
mov    (%rax),%edx
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    1230 <main+0xf0>
lea    0xe09(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    1396 <main+0x256>
mov    -0x31568(%rbp),%rdi
lea    -0x30d80(%rbp),%rdx
lea    0xdfa(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
mov    -0x31568(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2d8b(%rip),%rax
mov    (%rax),%edx
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    128d <main+0x14d>
lea    0xdcd(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    1396 <main+0x256>
mov    -0x31568(%rbp),%rdi
lea    0xd83(%rip),%rsi
lea    -0x30d84(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
movl   $0x0,-0x30d88(%rbp)
mov    -0x30d88(%rbp),%eax
cmp    -0x30d84(%rbp),%eax
jge    1375 <main+0x235>
mov    -0x31568(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2d12(%rip),%rax
mov    (%rax),%edx
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    1306 <main+0x1c6>
lea    0xd7c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    1396 <main+0x256>
mov    -0x31568(%rbp),%rdi
lea    -0x31560(%rbp),%rdx
lea    0xd24(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
lea    -0x30d80(%rbp),%rdi
lea    -0x31560(%rbp),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     1350 <main+0x210>
lea    0xd42(%rip),%rdi
call   1030 <printf@plt>
jmp    135c <main+0x21c>
lea    0xce5(%rip),%rdi
call   1030 <printf@plt>
jmp    1361 <main+0x221>
mov    -0x30d88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30d88(%rbp)
jmp    12b3 <main+0x173>
jmp    137a <main+0x23a>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11e3 <main+0xa3>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x62268,%rsp
mov    0x2e90(%rip),%r12
mov    (%r12),%edx
lea    0x7e0(%rsp),%rdi
mov    $0x30d40,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     12ab <main+0x16b>
lea    0xe82(%rip),%rsi
lea    0x7e0(%rsp),%rdi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    12c0 <main+0x180>
lea    0x7e0(%rsp),%rbx
lea    0x31520(%rsp),%r15
lea    0x10(%rsp),%r14
xor    %ebp,%ebp
jmp    11d1 <main+0x91>
cs nopw 0x0(%rax,%rax,1)
mov    0xc(%rsp),%ebp
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jge    12c0 <main+0x180>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x30d40,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     12d4 <main+0x194>
mov    %rbx,%rdi
lea    0xe0e(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x30d40,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     12dd <main+0x19d>
mov    %ebp,0xc(%rsp)
mov    %rbx,%rdi
lea    0xdd9(%rip),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
cmpl   $0x0,0x4(%rsp)
lea    0xdc4(%rip),%rbp
jle    11c0 <main+0x80>
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x30d40,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     12b4 <main+0x174>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
lea    0xd7b(%rip),%rdi
lea    0xdd5(%rip),%rax
cmove  %rax,%rdi
call   1030 <puts@plt>
add    $0x1,%r13d
cmp    0x4(%rsp),%r13d
jl     1250 <main+0x110>
jmp    11c0 <main+0x80>
lea    0xdb7(%rip),%rdi
jmp    12bb <main+0x17b>
lea    0xd4d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x62268,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd71(%rip),%rdi
jmp    12bb <main+0x17b>
lea    0xd41(%rip),%rdi
jmp    12bb <main+0x17b>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [30 x i8] c"Failure to read k from stdin\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"Failure to read S from stdin\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [40 x i8] c"Failure to get number of query strings\0A\00"
@.str.5 = [30 x i8] c"Failure to read T from stdin\0A\00"
@.str.6 = [3 x i8] c"y\0A\00"
@.str.7 = [3 x i8] c"n\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [200000 x i8]
%14 = alloca i32
%15 = alloca i32
%16 = alloca [2000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 200000, i32* %6
%17 = load i32, i32* %6
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %7
%20 = alloca i8, i64 %18
store i64 %18, i64* %8
%21 = load i32, i32* %6
%22 = load i32, i32* @stdin
%23 = call i32* @fgets(i8* %20, i32 %21, i32 %22)
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %27
25: ; preds = %2
%26 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
store i32 1, i32* %10
br label %82
27: ; preds = %2
%28 = call i32 (i8*, i8*, ...) @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %11)
store i32 0, i32* %12
br label %29
29: ; preds = %78, %27
%30 = load i32, i32* %12
%31 = load i32, i32* %11
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %81
33: ; preds = %29
%34 = load i32, i32* %6
%35 = load i32, i32* @stdin
%36 = call i32* @fgets(i8* %20, i32 %34, i32 %35)
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
store i32 1, i32* %10
br label %82
40: ; preds = %33
%41 = getelementptr inbounds [200000 x i8], [200000 x i8]* %13, i64 0, i64 0
%42 = call i32 (i8*, i8*, ...) @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %41)
%43 = load i32, i32* %6
%44 = load i32, i32* @stdin
%45 = call i32* @fgets(i8* %20, i32 %43, i32 %44)
%46 = icmp eq i32* %45, null
br i1 %46, label %47, label %49
47: ; preds = %40
%48 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
store i32 1, i32* %10
br label %82
49: ; preds = %40
%50 = call i32 (i8*, i8*, ...) @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
store i32 0, i32* %15
br label %51
51: ; preds = %74, %49
%52 = load i32, i32* %15
%53 = load i32, i32* %14
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %77
55: ; preds = %51
%56 = load i32, i32* %6
%57 = load i32, i32* @stdin
%58 = call i32* @fgets(i8* %20, i32 %56, i32 %57)
%59 = icmp eq i32* %58, null
br i1 %59, label %60, label %62
60: ; preds = %55
%61 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
store i32 1, i32* %10
br label %82
62: ; preds = %55
%63 = getelementptr inbounds [2000 x i8], [2000 x i8]* %16, i64 0, i64 0
%64 = call i32 (i8*, i8*, ...) @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %63)
%65 = getelementptr inbounds [200000 x i8], [200000 x i8]* %13, i64 0, i64 0
%66 = getelementptr inbounds [2000 x i8], [2000 x i8]* %16, i64 0, i64 0
%67 = call i32* @strstr(i8* %65, i8* %66)
%68 = icmp ne i32* %67, null
br i1 %68, label %69, label %71
69: ; preds = %62
%70 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %73
71: ; preds = %62
%72 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %73
73: ; preds = %71, %69
br label %74
74: ; preds = %73
%75 = load i32, i32* %15
%76 = add nsw i32 %75, 1
store i32 %76, i32* %15
br label %51
77: ; preds = %51
br label %78
78: ; preds = %77
%79 = load i32, i32* %12
%80 = add nsw i32 %79, 1
store i32 %80, i32* %12
br label %29
81: ; preds = %29
store i32 0, i32* %3
store i32 1, i32* %10
br label %82
82: ; preds = %81, %60, %47, %38, %25
%83 = load i8*, i8** %7
%84 = load i32, i32* %3
ret i32 %84
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%s\00"
@str = [2 x i8] c"n\00"
@str.8 = [2 x i8] c"y\00"
@str.9 = [29 x i8] c"Failure to read T from stdin\00"
@str.10 = [39 x i8] c"Failure to get number of query strings\00"
@str.11 = [29 x i8] c"Failure to read S from stdin\00"
@str.12 = [29 x i8] c"Failure to read k from stdin\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [200000 x i8]
%5 = alloca i32
%6 = alloca [2000 x i8]
%7 = alloca [200000 x i8]
%8 = getelementptr inbounds [200000 x i8], [200000 x i8]* %7, i64 0, i64 0
%9 = load i32, i32* @stdin
%10 = call i32* @fgets(i8* %8, i32 200000, i32 %9)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.12, i64 0, i64 0))
br label %62
14: ; preds = %2
%15 = bitcast i32* %3 to i8*
%16 = call i32 (i8*, i8*, ...) @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %61
19: ; preds = %14
%20 = getelementptr inbounds [200000 x i8], [200000 x i8]* %4, i64 0, i64 0
%21 = bitcast i32* %5 to i8*
%22 = getelementptr inbounds [2000 x i8], [2000 x i8]* %6, i64 0, i64 0
br label %23
23: ; preds = %19, %57
%24 = phi i32 [ 0, %19 ], [ %58, %57 ]
%25 = load i32, i32* @stdin
%26 = call i32* @fgets(i8* %8, i32 200000, i32 %25)
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.11, i64 0, i64 0))
br label %61
30: ; preds = %23
%31 = call i32 (i8*, i8*, ...) @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%32 = load i32, i32* @stdin
%33 = call i32* @fgets(i8* %8, i32 200000, i32 %32)
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.10, i64 0, i64 0))
br label %61
37: ; preds = %30
%38 = call i32 (i8*, i8*, ...) @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%39 = load i32, i32* %5
%40 = icmp sgt i32 %39, 0
br i1 %40, label %41, label %57
41: ; preds = %37, %46
%42 = phi i32 [ %52, %46 ], [ 0, %37 ]
%43 = load i32, i32* @stdin
%44 = call i32* @fgets(i8* %8, i32 200000, i32 %43)
%45 = icmp eq i32* %44, null
br i1 %45, label %55, label %46
46: ; preds = %41
%47 = call i32 (i8*, i8*, ...) @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%48 = call i32* @strstr(i8* %20, i8* %22)
%49 = icmp eq i32* %48, null
%50 = select i1 %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str.8, i64 0, i64 0)
%51 = call i32 @puts(i8* dereferenceable(1) %50)
%52 = add nuw nsw i32 %42, 1
%53 = load i32, i32* %5
%54 = icmp slt i32 %52, %53
br i1 %54, label %41, label %57
55: ; preds = %41
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.9, i64 0, i64 0))
br label %61
57: ; preds = %46, %37
%58 = add nuw nsw i32 %24, 1
%59 = load i32, i32* %3
%60 = icmp slt i32 %58, %59
br i1 %60, label %23, label %61
61: ; preds = %57, %14, %55, %35, %28
br label %62
62: ; preds = %61, %12
ret i32 0
}