#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() {
  int A, D, B, C, C2;
  int i, temp;
  scanf("%d", &A);
  scanf("%d", &D);
  while (A != 0 || D != 0) {
    scanf("%d", &B);
    for (i = 1; i < A; i++) {
      scanf("%d", &temp);
      if (temp < B) {
        B = temp;
      }
    }
    scanf("%d", &C);
    scanf("%d", &temp);
    if (C < temp) {
      C2 = temp;
    } else {
      C2 = C;
      C = temp;
    }
    for (i = 2; i < D; i++) {
      scanf("%d", &temp);
      if (temp < C) {
        C2 = C;
        C = temp;
      } else if (temp < C2) {
        C2 = temp;
      }
    }
    if (B >= C2) {
      printf("N\n");
    } else {
      printf("Y\n");
    }
    scanf("%d", &A);
    scanf("%d", &D);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeba(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x21(%rbp)
jne    1168 <main+0x48>
cmpl   $0x0,-0xc(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1178 <main+0x58>
jmp    12cb <main+0x1ab>
lea    0xe81(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d0 <main+0xb0>
lea    0xe5e(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11bd <main+0x9d>
mov    -0x20(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11c2 <main+0xa2>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118f <main+0x6f>
lea    0xe29(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe19(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1207 <main+0xe7>
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1213 <main+0xf3>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    127d <main+0x15d>
lea    0xdd3(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1253 <main+0x133>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    126a <main+0x14a>
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1265 <main+0x145>
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    126a <main+0x14a>
jmp    126f <main+0x14f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    121a <main+0xfa>
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jl     129a <main+0x17a>
lea    0xd73(%rip),%rdi
call   1030 <printf@plt>
jmp    12a6 <main+0x186>
lea    0xd65(%rip),%rdi
call   1030 <printf@plt>
lea    0xd53(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xd43(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
jmp    114f <main+0x2f>
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    0xecb(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
or     0x4(%rsp),%eax
je     1299 <main+0x179>
lea    0xe9c(%rip),%rbx
lea    0x10(%rsp),%r15
lea    0x4(%rsp),%r13
jmp    11b4 <main+0x94>
mov    %r12d,%eax
cmp    %eax,0x14(%rsp)
lea    0xe87(%rip),%rdi
lea    0xe7e(%rip),%rax
cmovl  %rax,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
or     0x4(%rsp),%eax
je     1299 <main+0x179>
mov    %rbx,%rdi
lea    0x14(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x2,0x8(%rsp)
jl     1200 <main+0xe0>
mov    $0x1,%ebp
jmp    11d9 <main+0xb9>
nop
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jge    1200 <main+0xe0>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
cmp    0x14(%rsp),%eax
jge    11d0 <main+0xb0>
mov    %eax,0x14(%rsp)
jmp    11d0 <main+0xb0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%r12d
mov    0x10(%rsp),%eax
cmp    %eax,%r12d
jge    1240 <main+0x120>
mov    %eax,%r12d
cmpl   $0x3,0x4(%rsp)
jl     1170 <main+0x50>
jmp    124f <main+0x12f>
cs nopw 0x0(%rax,%rax,1)
mov    %eax,0xc(%rsp)
cmpl   $0x3,0x4(%rsp)
jl     1170 <main+0x50>
mov    $0x2,%r14d
jmp    1279 <main+0x159>
nopw   0x0(%rax,%rax,1)
cmp    %r12d,%ecx
cmovl  %ecx,%r12d
mov    %r12d,%eax
add    $0x1,%r14d
cmp    0x4(%rsp),%r14d
jge    1173 <main+0x53>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%eax
cmp    %eax,%ecx
jge    1260 <main+0x140>
mov    %ecx,0xc(%rsp)
mov    %eax,%r12d
jmp    126a <main+0x14a>
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 = [3 x i8] c"N\0A\00"
@.str.2 = [3 x i8] c"Y\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
store i32 0, i32* %1
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %11
11: ; preds = %79, %0
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* %3
%16 = icmp ne i32 %15, 0
br label %17
17: ; preds = %14, %11
%18 = phi i1 [ true, %11 ], [ %16, %14 ]
br i1 %18, label %19, label %82
19: ; preds = %17
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
store i32 1, i32* %7
br label %21
21: ; preds = %33, %19
%22 = load i32, i32* %7
%23 = load i32, i32* %2
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %36
25: ; preds = %21
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%27 = load i32, i32* %8
%28 = load i32, i32* %4
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = load i32, i32* %8
store i32 %31, i32* %4
br label %32
32: ; preds = %30, %25
br label %33
33: ; preds = %32
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %21
36: ; preds = %21
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%39 = load i32, i32* %5
%40 = load i32, i32* %8
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = load i32, i32* %8
store i32 %43, i32* %6
br label %47
44: ; preds = %36
%45 = load i32, i32* %5
store i32 %45, i32* %6
%46 = load i32, i32* %8
store i32 %46, i32* %5
br label %47
47: ; preds = %44, %42
store i32 2, i32* %7
br label %48
48: ; preds = %68, %47
%49 = load i32, i32* %7
%50 = load i32, i32* %3
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %71
52: ; preds = %48
%53 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%54 = load i32, i32* %8
%55 = load i32, i32* %5
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %60
57: ; preds = %52
%58 = load i32, i32* %5
store i32 %58, i32* %6
%59 = load i32, i32* %8
store i32 %59, i32* %5
br label %67
60: ; preds = %52
%61 = load i32, i32* %8
%62 = load i32, i32* %6
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %66
64: ; preds = %60
%65 = load i32, i32* %8
store i32 %65, i32* %6
br label %66
66: ; preds = %64, %60
br label %67
67: ; preds = %66, %57
br label %68
68: ; preds = %67
%69 = load i32, i32* %7
%70 = add nsw i32 %69, 1
store i32 %70, i32* %7
br label %48
71: ; preds = %48
%72 = load i32, i32* %4
%73 = load i32, i32* %6
%74 = icmp sge i32 %72, %73
br i1 %74, label %75, label %77
75: ; preds = %71
%76 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %79
77: ; preds = %71
%78 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %79
79: ; preds = %77, %75
%80 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%81 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %11
82: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str = [2 x i8] c"Y\00"
@str.3 = [2 x i8] c"N\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %1
%14 = icmp ne i32 %13, 0
%15 = load i32, i32* %2
%16 = icmp ne i32 %15, 0
%17 = select i1 %14, i1 true, i1 %16
br i1 %17, label %18, label %73
18: ; preds = %0, %60
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%20 = load i32, i32* %1
%21 = icmp sgt i32 %20, 1
br i1 %21, label %22, label %33
22: ; preds = %18, %29
%23 = phi i32 [ %30, %29 ], [ 1, %18 ]
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%25 = load i32, i32* %5
%26 = load i32, i32* %3
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %29
28: ; preds = %22
store i32 %25, i32* %3
br label %29
29: ; preds = %22, %28
%30 = add nuw nsw i32 %23, 1
%31 = load i32, i32* %1
%32 = icmp slt i32 %30, %31
br i1 %32, label %22, label %33
33: ; preds = %29, %18
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%36 = load i32, i32* %4
%37 = load i32, i32* %5
%38 = icmp slt i32 %36, %37
br i1 %38, label %40, label %39
39: ; preds = %33
store i32 %37, i32* %4
br label %40
40: ; preds = %33, %39
%41 = phi i32 [ %36, %39 ], [ %37, %33 ]
%42 = load i32, i32* %2
%43 = icmp sgt i32 %42, 2
br i1 %43, label %44, label %60
44: ; preds = %40, %55
%45 = phi i32 [ %57, %55 ], [ 2, %40 ]
%46 = phi i32 [ %56, %55 ], [ %41, %40 ]
%47 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%48 = load i32, i32* %5
%49 = load i32, i32* %4
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %52
51: ; preds = %44
store i32 %48, i32* %4
br label %55
52: ; preds = %44
%53 = icmp slt i32 %48, %46
%54 = select i1 %53, i32 %48, i32 %46
br label %55
55: ; preds = %52, %51
%56 = phi i32 [ %49, %51 ], [ %54, %52 ]
%57 = add nuw nsw i32 %45, 1
%58 = load i32, i32* %2
%59 = icmp slt i32 %57, %58
br i1 %59, label %44, label %60
60: ; preds = %55, %40
%61 = phi i32 [ %41, %40 ], [ %56, %55 ]
%62 = load i32, i32* %3
%63 = icmp slt i32 %62, %61
%64 = select i1 %63, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str.3, i64 0, i64 0)
%65 = call i32 @puts(i8* dereferenceable(1) %64)
%66 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%67 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%68 = load i32, i32* %1
%69 = icmp ne i32 %68, 0
%70 = load i32, i32* %2
%71 = icmp ne i32 %70, 0
%72 = select i1 %69, i1 true, i1 %71
br i1 %72, label %18, label %73
73: ; preds = %60, %0
ret i32 0
}