{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Control.Monad.ST
import Control.Monad.State
import Control.Applicative
import Control.Arrow
import Control.Monad.Primitive
import Data.List
import Data.Array
import Data.Array.IO
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Generic.Mutable as VGM
import Data.Tuple
import Data.Function
import Text.Printf
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
listToTuple4 [a,b,c,d] = (a,b,c,d)
listToTuple5 [a,b,c,d,e] = (a,b,c,d,e)

readIntBS = fst . fromJust . BS.readInt

for = flip map

infixr 1 ?
(?) :: Bool -> (a,a) -> a
(?) b t = (if b then fst else snd) t

main :: IO ()
main = do
  [n,q] <- map read . words <$> getLine :: IO [Int]
  queries <- replicateM q $ map readIntBS . BS.words <$> BS.getLine :: IO [[Int]]
  let
    inf = 2^31-1
    f x y = if x == inf then y else x
    
  seg <- newRangeSegmentTree n inf min inf f const :: IO (IOURangeSegmentTree Int)

  forM_ queries $ \query -> do
    case query of
      [0,s,t,x] -> modifyRangeSegmentTree seg s (t+1) (const x)
      [1,s,t] -> print =<< findRangeSegmentTree seg s (t+1)

    --mapM_ print =<< showRangeSegmentTree seg
    --print ""
  

{-- 範囲更新・範囲取得のセグメント木--}
type MRangeSegmentTree v s a = ((v s a, a, (a -> a -> a)), (v s a, a, (a -> a -> a)), (a -> Int -> a))
-- 範囲取得用の(セグメント木,単位元,二項演算)、範囲更新用の(遅延セグメント木,単位元,二項演算)、
type STRangeSegmentTree s a = MRangeSegmentTree VM.MVector s a
type IORangeSegmentTree a = STRangeSegmentTree RealWorld a
type STURangeSegmentTree s a = MRangeSegmentTree VUM.MVector s a
type IOURangeSegmentTree a = STURangeSegmentTree RealWorld a


newRangeSegmentTree :: (PrimMonad m, VGM.MVector v a) => Int -> a -> (a -> a -> a) -> a -> (a -> a -> a) -> (a -> Int -> a) -> m (MRangeSegmentTree v (PrimState m) a)
newRangeSegmentTree n e1 f1 e2 f2 h = do
  tree1 <- VGM.replicate m e1
  tree2 <- VGM.replicate m e2
  return ((tree1,e1,f1),(tree2,e2,f2), h)
  where m = 2 * (2 ^ (ceiling $ logBase 2 (fromIntegral n))) - 1

modifyRangeSegmentTree :: (Eq a, PrimMonad m, VGM.MVector v a) => MRangeSegmentTree v (PrimState m) a -> Int -> Int -> (a -> a) -> m ()
modifyRangeSegmentTree ((tree1,e1,f1),(tree2,e2,f2),h) x y g = do
  aux 0 0 n
  where
    n = (VGM.length tree1) `div` 2 + 1
    aux i l r = do
      propag i
      if
        | r <= x || y <= l -> return ()
        | x <= l && r <= y -> VGM.read tree2 i >>= \a -> VGM.write tree2 i (g a)
        | otherwise -> aux (i*2+1) l ((l+r)`div`2) >> aux (i*2+2) ((l+r)`div`2) r
    propag i = do
      a <- VGM.read tree2 i
      when (a /= e2) $ do
        when (i<n-1) $ do
          VGM.read tree2 (i*2+1) >>= \b -> VGM.write tree2 (i*2+1) (f2 a b)
          VGM.read tree2 (i*2+2) >>= \b -> VGM.write tree2 (i*2+2) (f2 a b)
        VGM.read tree1 i >>= \a -> VGM.read tree2 i >>= \b ->
          if i<n-1 then
            VGM.write tree1 i (f1 (h b (n `div` (bit ((bitlen $ i+1)-1)))) a)
            else
            VGM.write tree1 i (f2 b a)
        VGM.write tree2 i e2
    bitlen n = if n == 0 then 0 else 1 + bitlen (div n 2)
                                                                                  

findRangeSegmentTree :: (Show a, Eq a, PrimMonad m, VGM.MVector v a) => MRangeSegmentTree v (PrimState m) a -> Int -> Int -> m a
findRangeSegmentTree ((tree1,e1,f1),(tree2,e2,f2),h) x y = do
  aux 0 0 n
  where
    n = (VGM.length tree1) `div` 2 + 1
    aux i l r = do
      propag i
      if
        | r <= x || y <= l -> return e1
        | x <= l && r <= y -> VGM.read tree1 i
        | otherwise -> aux (i*2+1) l ((l+r)`div`2) >>= \a -> aux (i*2+2) ((l+r)`div`2) r >>= \b -> return (f1 a b)
    propag i = do
      a <- VGM.read tree2 i
      when (a /= e2) $ do
        when (i<n-1) $ do
          VGM.read tree2 (i*2+1) >>= \b -> VGM.write tree2 (i*2+1) (f2 a b)
          VGM.read tree2 (i*2+2) >>= \b -> VGM.write tree2 (i*2+2) (f2 a b)
        VGM.read tree1 i >>= \a -> VGM.read tree2 i >>= \b ->
          if i<n-1 then
            VGM.write tree1 i (f1 (h b (n `div` (bit ((bitlen $ i+1)-1)))) a)
            else
            VGM.write tree1 i (f2 b a)
        VGM.write tree2 i e2
    bitlen n = if n == 0 then 0 else 1 + bitlen (div n 2)


showRangeSegmentTree :: (PrimMonad m, VGM.MVector v a, Show a) => MRangeSegmentTree v (PrimState m) a -> m [[(a,a)]]
showRangeSegmentTree ((tree1,_,_),(tree2,_,_),_) = do
  let
    n = (VGM.length tree1) `div` 2 + 1
    xs = init $ scanl (+) 0 (takeWhile (<=n) (iterate (*2) 1))
    ys = reverse xs

  forM (zip xs ys) $ \(s,s') -> do
    forM [s..s*2] $ \i -> VGM.read tree1 i >>= \a -> VGM.read tree2 i >>= \b -> return (a,b)


