import Control.Applicative
import Control.Monad.State

data SegTree a = Leaf a | Seg (SegTree a) a (SegTree a)  deriving (Show)

main = do
    [n,q] <- map read.words<$>getLine
    let seg = fromList $ replicate n (2^31 - 1)
    evalStateT (rmq n q) seg

rmq :: Int -> Int -> StateT (SegTree Int) IO ()
rmq s 0 = return ()
rmq s n = do
    q <- getQuery
    q s
    rmq s (n-1)

getQuery :: StateT (SegTree Int) IO (Int -> StateT (SegTree Int) IO ())
getQuery = do
    [c,x,y] <- lift $ map read.words<$>getLine
    case c of
      0 -> return $ (\s -> update s x y)
      1 -> return $ (\s -> find s x y)
      3 -> return $ (\s -> (get >>= \t -> lift $ print t))

update :: Int -> Int -> Int -> StateT (SegTree Int) IO ()
update s x y = modify (\seg -> updateSeg seg (s-1) x y)

find :: Int -> Int -> Int -> StateT (SegTree Int) IO ()
find s x y = do
    seg <- get
    lift $ print $ findSeg seg (0,s-1) (x,y)

val :: SegTree a -> a
val (Leaf a) = a
val (Seg _ a _) = a

fromList :: Ord a => [a] -> SegTree a
fromList xs = fl n xs
    where n = length xs
fl :: Ord a => Int -> [a] -> SegTree a
fl _ [x] = Leaf x
fl n xs  = Seg left v right
    where
        n' = n `quot` 2
        (xsL, xsR) = splitAt n' xs
        left = fl n' xsL
        right = fl (n-n') xsR
        v = min (val left) (val right)

updateSeg :: (Ord a) => SegTree a -> Int -> Int -> a -> SegTree a
updateSeg (Leaf v) _ _ x = Leaf x
updateSeg (Seg l v r) n i x
  | i <= n' = Seg left (min (val left) (val r)) r
  | otherwise = Seg l (min (val l) (val right)) right
    where
        n' = n `quot` 2
        left = updateSeg l n' i x
        right = updateSeg r (n-n') i x

findSeg :: Ord a => SegTree a -> (Int, Int) -> (Int, Int) -> a
findSeg (Leaf x) _ _ =  x
findSeg seg@(Seg l v r) (i,j) (s,t) 
  | s == i && t == j =  val seg
  | n' < s =  findSeg r (n'+1, j) (s,t)
  | t <= n' = findSeg l (i, n') (s,t)
  | s <= n' && t > n' = min (findSeg l (i,n') (s,n')) (findSeg r (n'+1,j) (n'+1,t))
  where n' = (i+j) `quot` 2

