#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 *, ...);
int main(void) {
  int i, j, a, b, n, m, t, y;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    y = 1;
    scanf("%d", &m);
    scanf("%d %d", &a, &b);
    t = a - b;
    for (j = 0; j < m - 1; j++) {
      scanf("%d %d", &a, &b);
      if (t != a - b && t != b - a)
        y = 0;
    }
    if (y == 1)
      printf("yes\n");
    else
      printf("no\n");
    if (i != n - 1)
      printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecd(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    124d <main+0x12d>
movl   $0x1,-0x24(%rbp)
lea    0xea1(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe8c(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11f6 <main+0xd6>
lea    0xe55(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x20(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    -0x14(%rbp),%ecx
cmp    %ecx,%eax
je     11e3 <main+0xc3>
mov    -0x20(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    -0x10(%rbp),%ecx
cmp    %ecx,%eax
je     11e3 <main+0xc3>
movl   $0x0,-0x24(%rbp)
jmp    11e8 <main+0xc8>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1193 <main+0x73>
cmpl   $0x1,-0x24(%rbp)
jne    1211 <main+0xf1>
lea    0xdff(%rip),%rdi
call   1030 <printf@plt>
jmp    121d <main+0xfd>
lea    0xdf3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     123a <main+0x11a>
lea    0xdd8(%rip),%rdi
call   1030 <printf@plt>
jmp    123f <main+0x11f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1148 <main+0x28>
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    $0x18,%rsp
lea    0xebe(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    1274 <main+0x144>
lea    0xea0(%rip),%r14
lea    0x4(%rsp),%rbp
lea    0xe91(%rip),%r12
lea    0x14(%rsp),%r13
lea    0x10(%rsp),%rbx
lea    0xe89(%rip),%r15
xor    %ecx,%ecx
jmp    119b <main+0x6b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ecx
cmp    %eax,%ecx
jge    1274 <main+0x144>
mov    %ecx,0xc(%rsp)
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x2,0x4(%rsp)
mov    %r15,%rdi
jl     1243 <main+0x113>
mov    0x14(%rsp),%r15d
sub    0x10(%rsp),%r15d
xor    %ebp,%ebp
mov    $0x1,%eax
nopl   0x0(%rax,%rax,1)
mov    %eax,%r14d
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
mov    0x10(%rsp),%ecx
mov    %eax,%edx
sub    %ecx,%edx
sub    %eax,%ecx
cmp    %ecx,%r15d
mov    $0x0,%eax
cmove  %r14d,%eax
cmp    %edx,%r15d
cmove  %r14d,%eax
add    $0x1,%ebp
mov    0x4(%rsp),%ecx
add    $0xffffffff,%ecx
cmp    %ecx,%ebp
jl     11e0 <main+0xb0>
cmp    $0x1,%eax
lea    0xdda(%rip),%rdi
lea    0xdd6(%rip),%r15
cmove  %r15,%rdi
lea    0xdc5(%rip),%r14
lea    0x4(%rsp),%rbp
call   1040 <puts@plt>
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    0xc(%rsp),%edx
cmp    %ecx,%edx
mov    %edx,%ecx
je     1190 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%eax
jmp    1190 <main+0x60>
xor    %eax,%eax
add    $0x18,%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 = [6 x i8] c"%d %d\00"
@.str.2 = [5 x i8] c"yes\0A\00"
@.str.3 = [4 x i8] c"no\0A\00"
@.str.4 = [2 x i8] c"\0A\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 i32
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
store i32 0, i32* %2
br label %11
11: ; preds = %59, %0
%12 = load i32, i32* %2
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %62
15: ; preds = %11
store i32 1, i32* %9
%16 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%17 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = sub nsw i32 %18, %19
store i32 %20, i32* %8
store i32 0, i32* %3
br label %21
21: ; preds = %41, %15
%22 = load i32, i32* %3
%23 = load i32, i32* %7
%24 = sub nsw i32 %23, 1
%25 = icmp slt i32 %22, %24
br i1 %25, label %26, label %44
26: ; preds = %21
%27 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%28 = load i32, i32* %8
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = sub nsw i32 %29, %30
%32 = icmp ne i32 %28, %31
br i1 %32, label %33, label %40
33: ; preds = %26
%34 = load i32, i32* %8
%35 = load i32, i32* %5
%36 = load i32, i32* %4
%37 = sub nsw i32 %35, %36
%38 = icmp ne i32 %34, %37
br i1 %38, label %39, label %40
39: ; preds = %33
store i32 0, i32* %9
br label %40
40: ; preds = %39, %33, %26
br label %41
41: ; preds = %40
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %21
44: ; preds = %21
%45 = load i32, i32* %9
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %51
49: ; preds = %44
%50 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %51
51: ; preds = %49, %47
%52 = load i32, i32* %2
%53 = load i32, i32* %6
%54 = sub nsw i32 %53, 1
%55 = icmp ne i32 %52, %54
br i1 %55, label %56, label %58
56: ; preds = %51
%57 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %58
58: ; preds = %56, %51
br label %59
59: ; preds = %58
%60 = load i32, i32* %2
%61 = add nsw i32 %60, 1
store i32 %61, i32* %2
br label %11
62: ; 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 = [3 x i8] c"no\00"
@str.5 = [4 x i8] c"yes\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %53
12: ; preds = %0, %49
%13 = phi i32 [ %51, %49 ], [ 0, %0 ]
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = sub nsw i32 %16, %17
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 1
br i1 %20, label %21, label %40
21: ; preds = %12, %21
%22 = phi i32 [ %32, %21 ], [ 1, %12 ]
%23 = phi i32 [ %33, %21 ], [ 0, %12 ]
%24 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%27 = sub nsw i32 %25, %26
%28 = icmp eq i32 %18, %27
%29 = sub nsw i32 %26, %25
%30 = icmp eq i32 %18, %29
%31 = select i1 %28, i1 true, i1 %30
%32 = select i1 %31, i32 %22, i32 0
%33 = add nuw nsw i32 %23, 1
%34 = load i32, i32* %4
%35 = add nsw i32 %34, -1
%36 = icmp slt i32 %33, %35
br i1 %36, label %21, label %37
37: ; preds = %21
%38 = icmp eq i32 %32, 1
%39 = select i1 %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0)
br label %40
40: ; preds = %37, %12
%41 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.5, i64 0, i64 0), %12 ], [ %39, %37 ]
%42 = call i32 @puts(i8* dereferenceable(1) %41)
%43 = load i32, i32* %3
%44 = add nsw i32 %43, -1
%45 = icmp eq i32 %13, %44
br i1 %45, label %49, label %46
46: ; preds = %40
%47 = call i32 @putchar(i32 10)
%48 = load i32, i32* %3
br label %49
49: ; preds = %40, %46
%50 = phi i32 [ %43, %40 ], [ %48, %46 ]
%51 = add nuw nsw i32 %13, 1
%52 = icmp slt i32 %51, %50
br i1 %52, label %12, label %53
53: ; preds = %49, %0
ret i32 0
}