Problem:
RMQ and RUQ

Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations:

update(s, t, x): change as, as+1, ..., at to x.

find(s, t): report the minimum element in as, as+1, ..., at.

Note that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.

Input

n q
query1
query2
:
queryq

In the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:

0 s t x

or

1 s t

The first digit represents the type of the query. '0' denotes update(s, t, x) and '1' denotes find(s, t).

Output

For each find operation, print the minimum value.

Constraints

1 ≤ n ≤ 100000

1 ≤ q ≤ 100000

0 ≤ s ≤ t < n

0 ≤ x < 231−1

Sample Input 1

3 5
0 0 1 1
0 1 2 3
0 2 2 2
1 0 2
1 1 2

Sample Output 1

1
2

Sample Input 2

1 3
1 0 0
0 0 0 5
1 0 0

Sample Output 2

2147483647
5

Solution in C++14 (judge verdict: Accepted)

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

template <typename T, typename E>
struct lazy_segment_tree {
    using F = function<T(T, T)>;
    using G = function<T(T, E)>;
    using H = function<E(E, E)>;
    int n, height;
    vector<T> data;
    vector<E> lazy;
    F f;
    G g;
    H h;
    T ti;
    E ei;
    lazy_segment_tree(F f, G g, H h, T ti, E ei) : f(f), g(g), h(h), ti(ti), ei(ei) {}
    void init(int n_) {
        n = 1; height = 0;
        while (n < n_) n <<= 1, height++;
        data.assign(2*n, ti);
        lazy.assign(2*n, ei);
    }
    void build(const vector<T> &v) {
        int n_ = (int)v.size();
        init(n_);
        for (int i = 0; i < n_; ++i) data[n+i] = v[i];
        for (int i = n-1; i >= 0; --i) {
            data[i] = f(data[i<<1|0], data[i<<1|1]);
        }
    }
    inline T reflect(int i) {
        return lazy[i] == ei ? data[i] : g(data[i], lazy[i]);
    }
    inline void propagate(int i) {
        if (lazy[i] == ei) return;
        lazy[i<<1|0] = h(lazy[i<<1|0], lazy[i]);
        lazy[i<<1|1] = h(lazy[i<<1|1], lazy[i]);
        data[i] = reflect(i);
        lazy[i] = ei;
    }
    inline void thrust(int i) {
        for (int k = height; k >= 1; --k) propagate(i>>k);
    }
    inline void recalc(int i) {
        while (i > 1) {
            i >>= 1;
            data[i] = f(reflect((i<<1|0)), reflect((i<<1|1)));
        }
    }
    void update(int a, int b, E x) {
        a += n; b += n;
        thrust(a);
        thrust(b-1);
        int l = a, r = b;
        while (l < r) {
            if (l & 1) lazy[l] = h(lazy[l], x), l++;
            if (r & 1) --r, lazy[r] = h(lazy[r], x);
            l >>= 1; r >>= 1;
        }
        recalc(a);
        recalc(b-1);
    }
    void set(int i, T x) {
        i += n;
        thrust(i);
        data[i] = x;
        lazy[i] = ei;
        recalc(i);
    }
    T fold(int a, int b) {
        a += n; b += n;
        thrust(a);
        thrust(b-1);
        T resl = ti, resr = ti;
        int l = a, r = b;
        while (l < r) {
            if (l & 1) resl = f(resl, reflect(l++));
            if (r & 1) resr = f(reflect(--r), resr);
            l >>= 1; r >>= 1;
        }
        return f(resl, resr);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, q;
    cin >> n >> q;
    auto f = [](int a, int b) { return min(a, b);};
    auto g = [](int a, int b) { return b == -1 ? a : b;};
    lazy_segment_tree<int, int> seg(f, g, g, (1LL<<31)-1, -1);
    seg.init(n);
    while (q--) {
        int com, s, t, x;
        cin >> com >> s >> t;
        if (com == 0) {
            cin >> x;
            seg.update(s, t+1, x);
        } else {
            cout << seg.fold(s, t+1) << endl;
        }
    }
}