program road_of_the_king
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer(8) :: dp(0:300,301,300) = 0_8
  integer :: n, m, i, j, k
  read(*,*) n, m
  dp(0,1,1) = 1_8
  do i = 0, m-1
    do j = 1, n
      do k = 1, n
        dp(i+1,j+1,k) = mod(dp(i+1,j+1,k)+dp(i,j,k)*int(n-j,8),md)
        dp(i+1,j,k) = mod(dp(i+1,j,k)+dp(i,j,k)*int(j-k,8),md)
        dp(i+1,j,j) = mod(dp(i+1,j,j)+dp(i,j,k)*int(k,8),md)
      end do
    end do
  end do
  write(*,'(i0)') dp(m,n,n)
end program road_of_the_king
; 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"

@_QFEdp = internal unnamed_addr global [300 x [301 x [301 x i64]]] zeroinitializer
@_QQcl.528e49f4b45b9c377bda51ea0f053d2d = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7741/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.528e49f4b45b9c377bda51ea0f053d2d, i32 6)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %5 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %1, i32 4)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %3)
  store i64 1, ptr @_QFEdp, align 16, !tbaa !3
  %7 = load i32, ptr %1, align 4, !tbaa !3
  %8 = add i32 %7, -1
  %9 = icmp sgt i32 %8, -1
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %10 = zext i32 %8 to i64
  %11 = load i32, ptr %2, align 4, !tbaa !3
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.preheader.lr.ph.us.us.preheader, label %._crit_edge

.preheader.lr.ph.us.us.preheader:                 ; preds = %.lr.ph
  %13 = zext i32 %11 to i64
  br label %.preheader.lr.ph.us.us

.preheader.lr.ph.us.us:                           ; preds = %.preheader.lr.ph.us.us.preheader, %._crit_edge14.split.us.us.us
  %indvars.iv24 = phi i64 [ 0, %.preheader.lr.ph.us.us.preheader ], [ %indvars.iv.next25, %._crit_edge14.split.us.us.us ]
  %indvars.iv.next25 = add nuw nsw i64 %indvars.iv24, 1
  %sext = shl i64 %indvars.iv.next25, 32
  %14 = ashr exact i64 %sext, 32
  br label %.preheader.us.us.us

.preheader.us.us.us:                              ; preds = %._crit_edge.us.us.us, %.preheader.lr.ph.us.us
  %indvars.iv20 = phi i64 [ %indvars.iv.next21, %._crit_edge.us.us.us ], [ 1, %.preheader.lr.ph.us.us ]
  %indvars.iv.next21 = add nuw nsw i64 %indvars.iv20, 1
  %sext28 = shl i64 %indvars.iv.next21, 32
  %15 = ashr exact i64 %sext28, 32
  %16 = add nsw i64 %15, -1
  %17 = add nsw i64 %indvars.iv20, -1
  %18 = trunc i64 %indvars.iv20 to i32
  %19 = sub i32 %11, %18
  %20 = sext i32 %19 to i64
  %21 = getelementptr [300 x [301 x [301 x i64]]], ptr @_QFEdp, i64 0, i64 %17, i64 %17, i64 %14
  br label %22

22:                                               ; preds = %22, %.preheader.us.us.us
  %indvars.iv = phi i64 [ %indvars.iv.next, %22 ], [ 1, %.preheader.us.us.us ]
  %23 = add nsw i64 %indvars.iv, -1
  %24 = getelementptr [300 x [301 x [301 x i64]]], ptr @_QFEdp, i64 0, i64 %23, i64 %16, i64 %14
  %25 = load i64, ptr %24, align 8, !tbaa !3
  %26 = getelementptr [300 x [301 x [301 x i64]]], ptr @_QFEdp, i64 0, i64 %23, i64 %17, i64 %indvars.iv24
  %27 = load i64, ptr %26, align 8, !tbaa !3
  %28 = mul i64 %27, %20
  %29 = add i64 %28, %25
  %30 = srem i64 %29, 1000000007
  store i64 %30, ptr %24, align 8, !tbaa !3
  %31 = getelementptr [300 x [301 x [301 x i64]]], ptr @_QFEdp, i64 0, i64 %23, i64 %17, i64 %14
  %32 = load i64, ptr %31, align 8, !tbaa !3
  %33 = load i64, ptr %26, align 8, !tbaa !3
  %34 = sub nsw i64 %indvars.iv20, %indvars.iv
  %35 = mul i64 %33, %34
  %36 = add i64 %35, %32
  %37 = srem i64 %36, 1000000007
  store i64 %37, ptr %31, align 8, !tbaa !3
  %38 = load i64, ptr %21, align 8, !tbaa !3
  %39 = mul i64 %33, %indvars.iv
  %40 = add i64 %38, %39
  %41 = srem i64 %40, 1000000007
  store i64 %41, ptr %21, align 8, !tbaa !3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, %13
  br i1 %exitcond.not, label %._crit_edge.us.us.us, label %22

._crit_edge.us.us.us:                             ; preds = %22
  %exitcond23.not = icmp eq i64 %indvars.iv20, %13
  br i1 %exitcond23.not, label %._crit_edge14.split.us.us.us, label %.preheader.us.us.us

._crit_edge14.split.us.us.us:                     ; preds = %._crit_edge.us.us.us
  %exitcond27.not = icmp eq i64 %indvars.iv24, %10
  br i1 %exitcond27.not, label %._crit_edge, label %.preheader.lr.ph.us.us

._crit_edge:                                      ; preds = %._crit_edge14.split.us.us.us, %.lr.ph, %0
  %42 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.528e49f4b45b9c377bda51ea0f053d2d, i32 17)
  %43 = load i32, ptr %1, align 4, !tbaa !3
  %44 = sext i32 %43 to i64
  %45 = load i32, ptr %2, align 4, !tbaa !3
  %46 = sext i32 %45 to i64
  %47 = add nsw i64 %46, -1
  %48 = getelementptr [300 x [301 x [301 x i64]]], ptr @_QFEdp, i64 0, i64 %47, i64 %47, i64 %44
  %49 = load i64, ptr %48, align 8, !tbaa !3
  %50 = call i1 @_FortranAioOutputInteger64(ptr %42, i64 %49)
  %51 = call i32 @_FortranAioEndIoStatement(ptr %42)
  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 ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

!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"}
