{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE MultiWayIf#-}
module Main where
import Data.Int (Int32)
import Data.Ix
import Control.Monad
import Data.Function
import Debug.Trace
import Data.Monoid
import Control.Applicative
newtype Min = Min {fromMin :: Int32} deriving (Ord,Show,Eq,Read)
instance Monoid Min where
  mempty = Min maxBound
  mappend = min
newtype Max = Max Int deriving (Ord,Show,Eq)
instance Monoid Max where
  mempty = Max minBound
  mappend = max

getInts :: IO [Int]
getInts = map read . words <$> getLine
main :: IO ()
main = do
  n:q:_ <- getInts
  let bst = fromList $ replicate n mempty :: STree Min
  queries <- replicateM q $  getInts
  go bst queries
  return ()
  where
    go _ [] = return ()
    go tree ([q,x,y]:queries)
      -- | traceShow tree False = undefined
      | q == 0 = do -- update
          let tree' = update tree x (Min $ fromIntegral y)
          go tree' queries
      | q == 1 = do -- find
          print . fromMin $ query tree (x, y)
          go tree queries

type Range = (Int,Int)
data STree v = Leaf !Int !v
             | Branch !Range !v !(STree v) !(STree v)
             deriving Show
range :: STree v-> Range
range !(Leaf r _) = (r,r)
range !(Branch r _ _ _) = r

val :: STree v -> v
val !(Leaf _ v) = v
val !(Branch _ v _ _) = v

left,right :: STree v -> Int
left = fst . Main.range
right = snd . Main.range

fromList :: Monoid v => [v] -> STree v
fromList !xs = makeTree 0 (length xs) xs

makeTree :: Monoid v => Int -> Int -> [v] -> STree v
makeTree !l !r !es = loop $ map (uncurry f) (zip [l..r] es)
  where
    loop ![x] = x
    loop !xs = loop $ buildTree xs
    f :: Int -> v -> STree v
    f !ix !v = Leaf ix v
    buildTree !(a:b:ys) = let v = val a `mappend` val b
                          in Branch (left a,right b) v a b : buildTree ys
    buildTree !x = x

query :: Monoid v => STree v -> (Int, Int) -> v
query t shape = loop t
  where
    loop (Leaf ix v)
      = if shape `inRange` ix then v else mempty
    loop (Branch (leftist,rightist) v lt rt)
      | shape `inRange` leftist
        && shape `inRange` rightist = v
      | otherwise = loop lt `mappend` loop rt

update :: Monoid v => STree v -> Int -> v -> STree v
update tree ix v = case tree of
  Leaf i _ -> if ix == i
              then Leaf i v
              else tree
  Branch rng _ l r
    | Main.range l `inRange` ix -> let l' = update l ix v
                        in Branch rng (val l' `mappend` val r) l' r
    | otherwise        -> let r' = update r ix v
                        in Branch rng (val l `mappend` val r') l r'