#![allow(non_snake_case)]

#[allow(unused_macros)]
macro_rules! debug {
    ( $x:ident [ $i:expr ] ) => {
        if cfg!(debug_assertions) {
            println!("{}[{}] = {:?}", stringify!($x), $i, $x[$i]);
        }
    };
    ( $x:ident [ $i:expr ][ $j:expr ] ) => {
        if cfg!(debug_assertions) {
            println!("{}[{}][{}] = {:?}", stringify!($x), $i, $j, $x[$i][$j]);
        }
    };
    ( $x:expr ) => {
        if cfg!(debug_assertions) {
            println!("{}:{} {} = {:?}", line!(), column!(), stringify!($x), $x);
        }
    };
}

/// Return the smallest power of 2 such that<br>
/// it is greater than or equal to <code>x</code>.
/// # Panics
/// <code>x == 0</code> will cause underflow.
pub fn clp(mut x: usize) -> usize {
    x -= 1;
    x = x | (x >>  1);
    x = x | (x >>  2);
    x = x | (x >>  4);
    x = x | (x >>  8);
    x = x | (x >> 16);
    x = x | (x >> 32);
    x + 1
}

struct RangeUpdateQuery {
    n: usize,
    a: Vec<Option<i64>>,
}

impl RangeUpdateQuery {
    pub fn new(m: usize) -> Self {
        let n = clp(m);
        Self {
            n: n,
            a: vec![Some(0); 2 * n - 1]
        }
    }

    fn _update(&mut self, update_first: usize, update_last: usize, new_value: i64, node: usize, node_first: usize, node_last: usize) {
        //println!("update_first = {}, update_last = {}, node = {}, node_first = {}, node_last = {}",
        //    update_first, update_last, node, node_first, node_last);
        if node_last <= update_first || update_last <= node_first {
            //println!("nothing to do");
            return;
        } else if update_first <= node_first && node_last <= update_last {
            //println!("change all elements");
            self.a[node] = Some(new_value);
        } else {
            //println!("split");
            if self.a[node].is_some() {
                self.a[2 * node + 1] = self.a[node];
                self.a[2 * node + 2] = self.a[node];
                self.a[node] = None;
            }
            let node_mid: usize = node_first + (node_last - node_first) / 2;
            self._update(update_first, update_last, new_value, 2 * node + 1, node_first, node_mid);
            self._update(update_first, update_last, new_value, 2 * node + 2, node_mid, node_last);
        }
    }

    pub fn update(&mut self, update_first: usize, update_last: usize, new_value: i64) {
        let n = self.n;
        self._update(update_first, update_last, new_value, 0, 0, n);
    }

    fn _query(&self, query_first: usize, query_last: usize, node: usize, node_first: usize, node_last: usize) -> i64 {
        //println!("query_first = {}, query_last = {}, node = {}, node_first = {}, node_last = {}",
            //query_first, query_last, node, node_first, node_last);
        if node_last <= query_first || query_last <= node_first {
            //println!("out of search scope, return unit");
            0
        } else if self.a[node].is_some() {
            let ret = self.a[node].unwrap() * (std::cmp::min(query_last, node_last) - std::cmp::max(query_first, node_first)) as i64;
            //println!("already calculated, return {:?}", ret);
            ret
        } else {
            //println!("new calculation start");
            let node_mid: usize = node_first + (node_last - node_first) / 2;
            let left: i64 = self._query(query_first, query_last, node * 2 + 1, node_first, node_mid);
            let right: i64 = self._query(query_first, query_last, node * 2 + 2, node_mid, node_last);
            //println!("new calculation end. return {:?}", (self.f)(left, right));
            left + right
        }
    }

    pub fn query(&self, first: usize, last: usize) -> i64 {
        self._query(first, last, 0, 0, self.n)
    }
}

fn main() {
    use std::io::{Write, BufWriter};

    let stdin = std::io::stdin();
    let mut stdin = my::io::InputReader::new(stdin.lock());
    let stdout = std::io::stdout();
    let mut stdout = BufWriter::new(stdout);

    let n: usize = stdin.read();
    let q: usize = stdin.read();
    let mut ruq = RangeUpdateQuery::new(n);
    for _ in 0..q {
        let query_type: i32 = stdin.read();
        if query_type == 0 {
            let first: usize = stdin.read();
            let last: usize = stdin.read::<usize>() + 1;
            let x: i64 = stdin.read();
            //println!("update query [{}, {}) <- {}", first, last, x);
            ruq.update(first, last, x);
        } else if query_type == 1 {
            let first: usize = stdin.read();
            let last: usize = stdin.read::<usize>() + 1;
            //println!("search query [{}, {})", first, last);
            stdout.write_fmt(format_args!("{}\n", ruq.query(first, last)));
        }
        //println!("");
    }
}

#[allow(unused_must_use)]
mod my {
    pub mod io {
        use std::io::{BufRead, ErrorKind, Result};
        use std::str::{FromStr, from_utf8};
        use std::fmt::Debug;

        pub fn read_word<R: BufRead>(r: &mut R, buf: &mut Vec<u8>)
                                              -> Result<usize> {
            let mut read = 0;
            loop {
                let (done, used) = {
                    let available = match r.fill_buf() {
                        Ok(n) => n,
                        Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,
                        Err(e) => return Err(e)
                    };
                    match available.iter().position(|&x| x == b'\n' || x == b' ') {
                        Some(i) => {
                            buf.extend_from_slice(&available[..i]);
                            (true, i + 1)
                        }
                        None => {
                            buf.extend_from_slice(available);
                            (false, available.len())
                        }
                    }
                };
                r.consume(used);
                read += used;
                if done || used == 0 {
                    return Ok(read);
                }
            }
        }

        pub struct InputReader<R: BufRead> {
            reader: R,
            buf: Vec<u8>,
        }

        impl<R: BufRead> InputReader<R> {
            pub fn new(reader: R) -> InputReader<R> {
                InputReader {
                    reader: reader,
                    buf: Vec::<u8>::new(),
                }
            }

            pub fn read_word(&mut self) {
                read_word(&mut self.reader, &mut self.buf);
            }
            
            pub fn read<T>(&mut self) -> T
                where T: FromStr,
                      T::Err: Debug
            {
                self.buf.clear();
                self.read_word();
                from_utf8(&self.buf).unwrap().trim().parse().unwrap()
            }
        }
    }
}


Measured memory_bytes: 9020