program cc
  implicit none
  integer :: n,k
  character :: s*128,ans*128,instead*1
  read *, n, k
  read *, s
  if (s(k:k) == "A") then
    instead = "a"
  else if (s(k:k) == "B") then
    instead = "b"
  else if (s(k:k) == "C") then
    instead = "c"
  end if

  if (k == 1) then
    ans = instead//s(2:n)
  else if (k == n) then
    ans = s(1:n-1)//instead
  else
    ans = s(1:k-1)//instead//s(k+1:n)
  end if
  print '(a)', ans
  stop
end program cc

; 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"

@_QFEans = internal global [128 x i8] undef
@_QFEs = internal global [128 x i8] undef
@_QQcl.d7595adec8165a7f6e51dbcb28fd228e = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4261/source.f\00"
@_QQcl.41 = linkonce constant [1 x i8] c"A"
@_QQcl.61 = linkonce local_unnamed_addr constant [1 x i8] c"a"
@_QQcl.42 = linkonce constant [1 x i8] c"B"
@_QQcl.62 = linkonce local_unnamed_addr constant [1 x i8] c"b"
@_QQcl.43 = linkonce constant [1 x i8] c"C"
@_QQcl.63 = linkonce local_unnamed_addr constant [1 x i8] c"c"
@_QQcl.286129 = linkonce constant [3 x i8] c"(a)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.d7595adec8165a7f6e51dbcb28fd228e, i32 5)
  %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)
  %7 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.d7595adec8165a7f6e51dbcb28fd228e, i32 6)
  %8 = call i1 @_FortranAioInputAscii(ptr %7, ptr nonnull @_QFEs, i64 128)
  %9 = call i32 @_FortranAioEndIoStatement(ptr %7)
  %10 = load i32, ptr %1, align 4, !tbaa !3
  %11 = sext i32 %10 to i64
  %12 = add nsw i64 %11, -1
  %13 = getelementptr [128 x [1 x i8]], ptr @_QFEs, i64 0, i64 %12
  %14 = call i32 @_FortranACharacterCompareScalar1(ptr %13, ptr nonnull @_QQcl.41, i64 1, i64 1)
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %0
  %.unpack20 = load i8, ptr @_QQcl.61, align 1, !tbaa !3
  br label %32

17:                                               ; preds = %0
  %18 = load i32, ptr %1, align 4, !tbaa !3
  %19 = sext i32 %18 to i64
  %20 = add nsw i64 %19, -1
  %21 = getelementptr [128 x [1 x i8]], ptr @_QFEs, i64 0, i64 %20
  %22 = call i32 @_FortranACharacterCompareScalar1(ptr %21, ptr nonnull @_QQcl.42, i64 1, i64 1)
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %17
  %.unpack19 = load i8, ptr @_QQcl.62, align 1, !tbaa !3
  br label %32

25:                                               ; preds = %17
  %26 = load i32, ptr %1, align 4, !tbaa !3
  %27 = sext i32 %26 to i64
  %28 = add nsw i64 %27, -1
  %29 = getelementptr [128 x [1 x i8]], ptr @_QFEs, i64 0, i64 %28
  %30 = call i32 @_FortranACharacterCompareScalar1(ptr %29, ptr nonnull @_QQcl.43, i64 1, i64 1)
  %31 = icmp eq i32 %30, 0
  %.unpack18 = load i8, ptr @_QQcl.63, align 1
  %spec.select = select i1 %31, i8 %.unpack18, i8 undef
  br label %32

32:                                               ; preds = %25, %16, %24
  %.sroa.0.0 = phi i8 [ %.unpack20, %16 ], [ %.unpack19, %24 ], [ %spec.select, %25 ]
  %33 = load i32, ptr %1, align 4, !tbaa !3
  %34 = icmp eq i32 %33, 1
  %35 = load i32, ptr %2, align 4, !tbaa !3
  br i1 %34, label %36, label %49

36:                                               ; preds = %32
  %37 = call i32 @llvm.smax.i32(i32 %35, i32 1)
  %38 = zext i32 %37 to i64
  %39 = alloca i8, i64 %38, align 1
  store i8 %.sroa.0.0, ptr %39, align 1
  %40 = icmp ugt i32 %37, 1
  br i1 %40, label %._crit_edge31, label %._crit_edge31.thread

._crit_edge31.thread:                             ; preds = %36
  %41 = call i64 @llvm.umin.i64(i64 %38, i64 128)
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 @_QFEans, ptr nonnull align 1 %39, i64 %41, i1 false)
  br label %.lr.ph33.preheader

._crit_edge31:                                    ; preds = %36
  %42 = add nsw i64 %38, -1
  %uglygep39 = getelementptr inbounds i8, ptr %39, i64 1
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %uglygep39, ptr nonnull align 1 getelementptr inbounds ([128 x i8], ptr @_QFEs, i64 0, i64 1), i64 %42, i1 false), !tbaa !3
  %43 = call i64 @llvm.umin.i64(i64 %38, i64 128)
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 @_QFEans, ptr nonnull align 1 %39, i64 %43, i1 false)
  %44 = icmp ult i32 %37, 128
  br i1 %44, label %.lr.ph33.preheader, label %.loopexit

.lr.ph33.preheader:                               ; preds = %._crit_edge31.thread, %._crit_edge31
  %45 = phi i64 [ %41, %._crit_edge31.thread ], [ %43, %._crit_edge31 ]
  %46 = sub nuw nsw i64 128, %45
  %uglygep40 = getelementptr i8, ptr @_QFEans, i64 %45
  %smin41 = call i64 @llvm.smin.i64(i64 %46, i64 1)
  %47 = add nuw nsw i64 %smin41, %45
  %48 = sub nuw nsw i64 129, %47
  br label %.loopexit.sink.split

49:                                               ; preds = %32
  %50 = icmp eq i32 %33, %35
  %51 = add i32 %33, -1
  %52 = call i32 @llvm.smax.i32(i32 %51, i32 0)
  %53 = zext i32 %52 to i64
  %54 = add nuw nsw i64 %53, 1
  %55 = alloca i8, i64 %54, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %55, ptr nonnull align 16 @_QFEs, i64 %53, i1 false)
  %56 = getelementptr [1 x i8], ptr %55, i64 %53
  store i8 %.sroa.0.0, ptr %56, align 1, !tbaa !3
  br i1 %50, label %57, label %63

57:                                               ; preds = %49
  %58 = call i64 @llvm.umin.i64(i64 %54, i64 128)
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 @_QFEans, ptr nonnull align 1 %55, i64 %58, i1 false)
  %59 = icmp ult i32 %52, 127
  br i1 %59, label %.lr.ph28.preheader, label %.loopexit

.lr.ph28.preheader:                               ; preds = %57
  %60 = sub nuw nsw i64 128, %58
  %uglygep37 = getelementptr i8, ptr @_QFEans, i64 %58
  %smin38 = call i64 @llvm.smin.i64(i64 %60, i64 1)
  %61 = add nuw nsw i64 %smin38, %58
  %62 = sub nuw nsw i64 129, %61
  br label %.loopexit.sink.split

63:                                               ; preds = %49
  %64 = add i32 %33, 1
  %65 = sext i32 %64 to i64
  %66 = sext i32 %35 to i64
  %67 = sub nsw i64 %66, %65
  %68 = call i64 @llvm.smax.i64(i64 %67, i64 -1)
  %69 = add nsw i64 %68, 1
  %70 = add nuw nsw i64 %69, %54
  %71 = alloca i8, i64 %70, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(1) %71, ptr noundef nonnull align 1 dereferenceable(1) %55, i64 %54, i1 false)
  %72 = icmp sgt i64 %67, -1
  br i1 %72, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %63
  %73 = add nsw i64 %65, -1
  %74 = getelementptr [128 x [1 x i8]], ptr @_QFEs, i64 0, i64 %73
  %uglygep = getelementptr i8, ptr %71, i64 %54
  %75 = add nsw i64 %68, 2
  %smin = call i64 @llvm.smin.i64(i64 %69, i64 1)
  %76 = sub nuw nsw i64 %75, %smin
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %uglygep, ptr align 1 %74, i64 %76, i1 false), !tbaa !3
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.preheader, %63
  %77 = call i64 @llvm.smin.i64(i64 %70, i64 128)
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 @_QFEans, ptr nonnull align 1 %71, i64 %77, i1 false)
  %.not = icmp sgt i64 %70, 127
  br i1 %.not, label %.loopexit, label %.lr.ph26.preheader

.lr.ph26.preheader:                               ; preds = %._crit_edge
  %78 = sub nuw nsw i64 128, %77
  %uglygep36 = getelementptr i8, ptr @_QFEans, i64 %77
  br label %.loopexit.sink.split

.loopexit.sink.split:                             ; preds = %.lr.ph33.preheader, %.lr.ph28.preheader, %.lr.ph26.preheader
  %.sink = phi i64 [ %78, %.lr.ph26.preheader ], [ %62, %.lr.ph28.preheader ], [ %48, %.lr.ph33.preheader ]
  %uglygep36.sink = phi ptr [ %uglygep36, %.lr.ph26.preheader ], [ %uglygep37, %.lr.ph28.preheader ], [ %uglygep40, %.lr.ph33.preheader ]
  call void @llvm.memset.p0.i64(ptr align 1 %uglygep36.sink, i8 32, i64 %.sink, i1 false), !tbaa !3
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.sink.split, %._crit_edge, %57, %._crit_edge31
  %79 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.286129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.d7595adec8165a7f6e51dbcb28fd228e, i32 22)
  %80 = call i1 @_FortranAioOutputAscii(ptr %79, ptr nonnull @_QFEans, i64 128)
  %81 = call i32 @_FortranAioEndIoStatement(ptr %79)
  %82 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

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 @_FortranAioInputAscii(ptr, ptr, i64) local_unnamed_addr

declare i32 @_FortranACharacterCompareScalar1(ptr, ptr, i64, i64) local_unnamed_addr

declare ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, 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 i64 @llvm.smax.i64(i64, i64) #1

; 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 i64 @llvm.smin.i64(i64, i64) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

attributes #0 = { noreturn }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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"}
