program main
  integer, allocatable :: i(:, :)
  read (*, *) n
  allocate(i(3, 0:n))
  i(:, 0) = (/0, 0, 0/)
  read (*, *) i(:, 1:n)
  do k = 1, n
    jx = abs(i(2, k) - i(2, k - 1)) + abs(i(3, k) - i(3, k - 1))
    jt = i(1, k) - i(1, k - 1)
    if (jx > jt .or. ibits(jx, 0, 1) /= ibits(jt, 0, 1)) then
      write (*, *) "No"
      stop
    endif
  enddo
  write (*, *) "Yes"
end

; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QFEi.0 = internal unnamed_addr global ptr null
@_QFEi.10 = internal unnamed_addr global i64 1
@_QQcl.71d8d9e6fa1e59ff05b29f4da89d084c = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6398/source.f\00"
@_QQcl.4E6F = linkonce constant [2 x i8] c"No"
@_QQcl.596573 = linkonce constant [3 x i8] c"Yes"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, align 8
  %2 = alloca i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.71d8d9e6fa1e59ff05b29f4da89d084c, i32 3)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = load i32, ptr %2, align 4, !tbaa !3
  %7 = call i32 @llvm.smax.i32(i32 %6, i32 -1)
  %8 = sext i32 %7 to i64
  %9 = add nsw i64 %8, 1
  %10 = mul nuw nsw i64 %9, 12
  %11 = call ptr @malloc(i64 %10)
  %12 = icmp eq i64 %9, 0
  %13 = zext i1 %12 to i64
  store ptr %11, ptr @_QFEi.0, align 8, !tbaa !7
  store i64 %13, ptr @_QFEi.10, align 8, !tbaa !7
  %14 = select i1 %12, i64 -12, i64 0
  %uglygep = getelementptr i8, ptr %11, i64 %14
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %uglygep, i8 0, i64 12, i1 false)
  %15 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.71d8d9e6fa1e59ff05b29f4da89d084c, i32 6)
  %.unpack = load ptr, ptr @_QFEi.0, align 8, !tbaa !7
  %.unpack178.unpack179.unpack = load i64, ptr @_QFEi.10, align 8, !tbaa !7
  %16 = load i32, ptr %2, align 4, !tbaa !3
  %17 = sub i64 1, %.unpack178.unpack179.unpack
  %18 = mul i64 %17, 3
  %19 = call i32 @llvm.smax.i32(i32 %16, i32 0)
  %20 = zext i32 %19 to i64
  %21 = getelementptr i32, ptr %.unpack, i64 %18
  store ptr %21, ptr %1, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %1, i64 0, i32 1
  store i64 4, ptr %.fca.1.gep, align 8, !tbaa !7
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %1, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %1, i64 0, i32 3
  store i8 2, ptr %.fca.3.gep, align 4, !tbaa !7
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %1, i64 0, i32 4
  store i8 9, ptr %.fca.4.gep, align 1, !tbaa !7
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %1, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %1, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  store i64 3, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %.fca.7.1.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 1, i64 0
  store i64 1, ptr %.fca.7.1.0.gep, align 8, !tbaa !7
  %.fca.7.1.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 1, i64 1
  store i64 %20, ptr %.fca.7.1.1.gep, align 8, !tbaa !7
  %.fca.7.1.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [2 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 1, i64 2
  store i64 12, ptr %.fca.7.1.2.gep, align 8, !tbaa !7
  %22 = call i1 @_FortranAioInputDescriptor(ptr %15, ptr nonnull %1)
  %23 = call i32 @_FortranAioEndIoStatement(ptr %15)
  %24 = load i32, ptr %2, align 4, !tbaa !3
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %.unpack187 = load ptr, ptr @_QFEi.0, align 8, !tbaa !7
  %.unpack194.unpack195.unpack = load i64, ptr @_QFEi.10, align 8, !tbaa !7
  br label %26

26:                                               ; preds = %.lr.ph, %66
  %.0204 = phi i32 [ 1, %.lr.ph ], [ %67, %66 ]
  %27 = sext i32 %.0204 to i64
  %28 = sub i64 %27, %.unpack194.unpack195.unpack
  %29 = mul i64 %28, 3
  %30 = add i64 %29, 1
  %31 = getelementptr i32, ptr %.unpack187, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !3
  %33 = add i32 %.0204, -1
  %34 = sext i32 %33 to i64
  %35 = sub i64 %34, %.unpack194.unpack195.unpack
  %36 = mul i64 %35, 3
  %37 = add i64 %36, 1
  %38 = getelementptr i32, ptr %.unpack187, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !3
  %40 = sub i32 %32, %39
  %41 = call i32 @llvm.abs.i32(i32 %40, i1 false)
  %42 = add i64 %29, 2
  %43 = getelementptr i32, ptr %.unpack187, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !3
  %45 = add i64 %36, 2
  %46 = getelementptr i32, ptr %.unpack187, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !3
  %48 = sub i32 %44, %47
  %49 = call i32 @llvm.abs.i32(i32 %48, i1 false)
  %50 = add i32 %49, %41
  %51 = getelementptr i32, ptr %.unpack187, i64 %29
  %52 = load i32, ptr %51, align 4, !tbaa !3
  %53 = getelementptr i32, ptr %.unpack187, i64 %36
  %54 = load i32, ptr %53, align 4, !tbaa !3
  %55 = sub i32 %52, %54
  %56 = icmp sgt i32 %50, %55
  %57 = xor i32 %50, %55
  %58 = and i32 %57, 1
  %59 = icmp ne i32 %58, 0
  %60 = or i1 %56, %59
  br i1 %60, label %61, label %66

61:                                               ; preds = %26
  %62 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.71d8d9e6fa1e59ff05b29f4da89d084c, i32 11)
  %63 = call i1 @_FortranAioOutputAscii(ptr %62, ptr nonnull @_QQcl.4E6F, i64 2)
  %64 = call i32 @_FortranAioEndIoStatement(ptr %62)
  %65 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

66:                                               ; preds = %26
  %67 = add nuw i32 %.0204, 1
  %exitcond.not = icmp eq i32 %.0204, %24
  br i1 %exitcond.not, label %._crit_edge, label %26

._crit_edge:                                      ; preds = %66, %0
  %68 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.71d8d9e6fa1e59ff05b29f4da89d084c, i32 15)
  %69 = call i1 @_FortranAioOutputAscii(ptr %68, ptr nonnull @_QQcl.596573, i64 3)
  %70 = call i32 @_FortranAioEndIoStatement(ptr %68)
  ret void
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputAscii(ptr, ptr, i64) local_unnamed_addr

declare {} @_FortranAStopStatement(i32, i1, i1) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
