#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 t, S, E, n, i, part;
  long int tstart, tend;
  scanf("%d", &t);
  while (t--) {
    part = 1;
    scanf("%d %d", &S, &E);
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
      scanf("%ld %ld", &tstart, &tend);
      if (!(tstart < S && tend <= S || tstart >= E))
        part = 0;
    }
    if (part)
      printf("\nYES");
    else
      printf("\nNO");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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     1226 <main+0x106>
movl   $0x1,-0x1c(%rbp)
lea    0xe9d(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe8a(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11fa <main+0xda>
lea    0xe68(%rip),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    %rcx,%rax
jge    11cf <main+0xaf>
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    %rcx,%rax
jle    11e7 <main+0xc7>
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmp    %rcx,%rax
jge    11e7 <main+0xc7>
movl   $0x0,-0x1c(%rbp)
jmp    11ec <main+0xcc>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118b <main+0x6b>
cmpl   $0x0,-0x1c(%rbp)
je     1215 <main+0xf5>
lea    0xe03(%rip),%rdi
call   1030 <printf@plt>
jmp    1221 <main+0x101>
lea    0xdf7(%rip),%rdi
call   1030 <printf@plt>
jmp    1141 <main+0x21>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xece(%rip),%rdi
xor    %r12d,%r12d
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    115c <main+0x3c>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xeab(%rip),%rbx
lea    0xe9c(%rip),%rbp
lea    0x20(%rsp),%r14
lea    0x18(%rsp),%r15
jmp    118c <main+0x6c>
cs nopw 0x0(%rax,%rax,1)
call   1030 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     114b <main+0x2b>
lea    0xe6d(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xe58(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
mov    %rbx,%rdi
jle    1180 <main+0x60>
xor    %r13d,%r13d
mov    $0x1,%ebx
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x20(%rsp),%rax
movslq 0x14(%rsp),%rcx
movslq 0x10(%rsp),%rdx
cmp    %rdx,%rax
mov    %ebx,%edx
cmovl  %r12d,%edx
cmp    %rcx,0x18(%rsp)
cmovg  %edx,%ebx
cmp    %rcx,%rax
cmovge %edx,%ebx
add    $0x1,%r13d
cmp    0x8(%rsp),%r13d
jl     11d0 <main+0xb0>
test   %ebx,%ebx
lea    0xdf4(%rip),%rbx
mov    %rbx,%rdi
lea    0xdef(%rip),%rax
cmove  %rax,%rdi
jmp    1180 <main+0x60>

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

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