#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*/);
scalar_t__ isSatisfiable(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int main(void) {
  char expr[1000 + 2], trash[1000 + 2];
  int T;
  scanf("%d", &T);
  fgets(trash, 1000 + 2, stdin);
  while (T) {
    fgets(expr, 1000 + 2, stdin);
    if (isSatisfiable(expr))
      printf("YES\n");
    else
      printf("NO\n");
    T--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x7e4(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x7e0(%rbp),%rdi
mov    0x2e75(%rip),%rax
mov    (%rax),%edx
mov    $0x3ea,%esi
call   1040 <fgets@plt>
cmpl   $0x0,-0x7e4(%rbp)
je     11ed <main+0xad>
lea    -0x3f0(%rbp),%rdi
mov    0x2e4e(%rip),%rax
mov    (%rax),%edx
mov    $0x3ea,%esi
call   1040 <fgets@plt>
lea    -0x3f0(%rbp),%rdi
call   1050 <isSatisfiable@plt>
cmp    $0x0,%rax
je     11cd <main+0x8d>
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
jmp    11d9 <main+0x99>
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
mov    -0x7e4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x7e4(%rbp)
jmp    117f <main+0x3f>
xor    %eax,%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x7f8,%rsp
lea    0xeab(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2e82(%rip),%r14
mov    (%r14),%edx
lea    0x10(%rsp),%rdi
mov    $0x3ea,%esi
call   1040 <fgets@plt>
cmpl   $0x0,0xc(%rsp)
je     11ce <main+0x8e>
lea    0x400(%rsp),%rbx
lea    0xe75(%rip),%r15
lea    0xe71(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x3ea,%esi
call   1040 <fgets@plt>
mov    %rbx,%rdi
call   1050 <isSatisfiable@plt>
test   %rax,%rax
mov    %r12,%rdi
cmove  %r15,%rdi
call   1030 <puts@plt>
addl   $0xffffffff,0xc(%rsp)
jne    11a0 <main+0x60>
xor    %eax,%eax
add    $0x7f8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.1 = [5 x i8] c"YES\0A\00"
@.str.2 = [4 x i8] c"NO\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1002 x i8]
%3 = alloca [1002 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%6 = getelementptr inbounds [1002 x i8], [1002 x i8]* %3, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 1002, i32 %7)
br label %9
9: ; preds = %23, %0
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %9
%13 = getelementptr inbounds [1002 x i8], [1002 x i8]* %2, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %13, i32 1002, i32 %14)
%16 = getelementptr inbounds [1002 x i8], [1002 x i8]* %2, i64 0, i64 0
%17 = call i64 @isSatisfiable(i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %23
21: ; preds = %12
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
%24 = load i32, i32* %4
%25 = add nsw i32 %24, -1
store i32 %25, i32* %4
br label %9
26: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@stdin = global i32 0
@str = [3 x i8] c"NO\00"
@str.3 = [4 x i8] c"YES\00"
define i32 @main() {
%1 = alloca [1002 x i8]
%2 = alloca [1002 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [1002 x i8], [1002 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [1002 x i8], [1002 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %5, i32 1002, i32 %8)
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 0
br i1 %11, label %22, label %12
12: ; preds = %0, %12
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %4, i32 1002, i32 %13)
%15 = call i64 @isSatisfiable(i8* %4)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.3, i64 0, i64 0)
%18 = call i32 @puts(i8* dereferenceable(1) %17)
%19 = load i32, i32* %3
%20 = add nsw i32 %19, -1
store i32 %20, i32* %3
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %12
22: ; preds = %12, %0
ret i32 0
}