#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 *, char);
int /*<<< orphan*/ scanf(char *, ...);
int main(int argc, const char *argv[]) {
  int n, m, i, j;
  char t[100000], temp[10], d;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &m);
    for (j = 0; j < m; j++) {
      scanf("%s", temp);
      t[j] = temp[0];
    }
    t[j] = '\0';
    scanf("%s", &temp);
    d = temp[0];
    for (j = 0; t[j + 1] != '\0'; j++) {
      if (t[j] != d)
        printf("%c ", t[j]);
    }
    printf("%c\n", t[j]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x186d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec0(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1270 <main+0x150>
lea    0xe9b(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b7 <main+0x97>
lea    -0x186ca(%rbp),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x186ca(%rbp),%cl
movslq -0x20(%rbp),%rax
mov    %cl,-0x186c0(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1177 <main+0x57>
movslq -0x20(%rbp),%rax
movb   $0x0,-0x186c0(%rbp,%rax,1)
lea    0xe39(%rip),%rdi
lea    -0x186ca(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x186ca(%rbp),%al
mov    %al,-0x186cb(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x186c0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     124a <main+0x12a>
movslq -0x20(%rbp),%rax
movsbl -0x186c0(%rbp,%rax,1),%eax
ff
movsbl -0x186cb(%rbp),%ecx
cmp    %ecx,%eax
je     1237 <main+0x117>
movslq -0x20(%rbp),%rax
lea    0xddc(%rip),%rdi
movsbl -0x186c0(%rbp,%rax,1),%esi
ff
call   1030 <printf@plt>
jmp    123c <main+0x11c>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11eb <main+0xcb>
movslq -0x20(%rbp),%rax
lea    0xdb5(%rip),%rdi
movsbl -0x186c0(%rbp,%rax,1),%esi
ff
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1152 <main+0x32>
xor    %eax,%eax
add    $0x186d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x186c8,%rsp
lea    0xec8(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x10(%rsp)
jle    1248 <main+0x128>
lea    0xead(%rip),%r12
lea    0x16(%rsp),%r13
xor    %r14d,%r14d
jmp    1184 <main+0x64>
xor    %eax,%eax
mov    %eax,%eax
movsbl 0x20(%rsp,%rax,1),%esi
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
add    $0x1,%r14d
cmp    0x10(%rsp),%r14d
jge    1248 <main+0x128>
lea    0xe75(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11e0 <main+0xc0>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movzbl 0x16(%rsp),%eax
mov    %al,0x20(%rsp,%r15,1)
add    $0x1,%r15
movslq 0xc(%rsp),%rax
cmp    %rax,%r15
jl     11b0 <main+0x90>
jmp    11e3 <main+0xc3>
nopw   0x0(%rax,%rax,1)
xor    %r15d,%r15d
mov    %r15d,%eax
movb   $0x0,0x20(%rsp,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpb   $0x0,0x21(%rsp)
je     1160 <main+0x40>
mov    0x16(%rsp),%bl
xor    %ebp,%ebp
lea    0xdf6(%rip),%r15
jmp    1232 <main+0x112>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x1(%rbp),%rax
cmpb   $0x0,0x22(%rsp,%rbp,1)
mov    %rax,%rbp
je     1162 <main+0x42>
movzbl 0x20(%rsp,%rbp,1),%eax
cmp    %bl,%al
je     1220 <main+0x100>
movsbl %al,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
jmp    1220 <main+0x100>
xor    %eax,%eax
add    $0x186c8,%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 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%c \00"
@.str.3 = [4 x i8] c"%c\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [100000 x i8]
%11 = alloca [10 x i8]
%12 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
store i32 0, i32* %8
br label %14
14: ; preds = %75, %2
%15 = load i32, i32* %8
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %78
18: ; preds = %14
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
store i32 0, i32* %9
br label %20
20: ; preds = %32, %18
%21 = load i32, i32* %9
%22 = load i32, i32* %7
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %35
24: ; preds = %20
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%28 = load i8, i8* %27
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100000 x i8], [100000 x i8]* %10, i64 0, i64 %30
store i8 %28, i8* %31
br label %32
32: ; preds = %24
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %20
35: ; preds = %20
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [100000 x i8], [100000 x i8]* %10, i64 0, i64 %37
store i8 0, i8* %38
%39 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), [10 x i8]* %11)
%40 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%41 = load i8, i8* %40
store i8 %41, i8* %12
store i32 0, i32* %9
br label %42
42: ; preds = %66, %35
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [100000 x i8], [100000 x i8]* %10, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %69
50: ; preds = %42
%51 = load i32, i32* %9
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [100000 x i8], [100000 x i8]* %10, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = load i8, i8* %12
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %55, %57
br i1 %58, label %59, label %65
59: ; preds = %50
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [100000 x i8], [100000 x i8]* %10, i64 0, i64 %61
%63 = load i8, i8* %62
%64 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8 signext %63)
br label %65
65: ; preds = %59, %50
br label %66
66: ; preds = %65
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
store i32 %68, i32* %9
br label %42
69: ; preds = %42
%70 = load i32, i32* %9
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [100000 x i8], [100000 x i8]* %10, i64 0, i64 %71
%73 = load i8, i8* %72
%74 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8 signext %73)
br label %75
75: ; preds = %69
%76 = load i32, i32* %8
%77 = add nsw i32 %76, 1
store i32 %77, i32* %8
br label %14
78: ; preds = %14
ret i32 0
}

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