Problem: 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.

Constraints

* 1 ≤ n ≤ 100000
* 1 ≤ q ≤ 100000
* 0 ≤ s ≤ t < n
* 0 ≤ x < 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.

Examples

Input

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


Output

1
2


Input

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


Output

2147483647
5

Solution (in CPP):

Solution:
#include <bits/stdc++.h>

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;
using ui = unsigned int;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

struct SegmentTree{
    SegmentTree(int n){
        size = 1;
        while(size < n){
            size *= 2;
        }
        for(int i=1;i<2*size;++i){
            data[i] = D;
        }
    }
    void propagate(int k){
        if(delayed[k]){
            data[k] = data2[k];
            if(k < size){
                data2[k*2] = data2[k*2+1] = data2[k];
                delayed[k*2] = delayed[k*2+1] = true;
            }
            delayed[k] = false;
        }
    }
    inline void update(int l, int r, ui x){
        _update(1, 0, size, l, r, x);
    }
    void _update(int k, int a, int b, int l, int r, ui x){
        propagate(k);

        if(b <= l || r <= a){return;}
        if(l <= a && b <= r){
            data2[k] = x;
            delayed[k] = true;
            propagate(k);
        }else{
            int mid = (a + b) / 2;
            _update(k * 2, a, mid, l, r, x);
            _update(k * 2 + 1, mid, b, l, r, x);
            data[k] = min(data[k*2], data[k*2+1]);
        }
    }
    ui minimum(int l, int r){
        return _minimum(1, 0, size, l, r);
    }
    inline ui _minimum(int k, int a, int b, int l, int r){
        propagate(k);

        if(b <= l || r <= a){return D;}
        if(l <= a && b <= r){return data[k];}
        int mid = (a + b) / 2;
        ui vl = _minimum(k * 2, a, mid, l, r),
            vr = _minimum(k * 2 + 1, mid, b, l, r);
        return min(vl, vr);
    }
    
    int size;
    bool delayed[400100]; // 伝搬されていないときtrue
    ui data[400100], data2[400100];
    const ui D = (1u << 31) - 1;
};

int N, Q;
SegmentTree segtree(100000);

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

    std::cin >> N >> Q;

    for(int i=0;i<Q;++i){
        int type, s, t;

        std::cin >> type >> s >> t;

        if(type == 0){
            ui x;
            std::cin >> x;

            segtree.update(s, t + 1, x);
        }else{
            std::cout << segtree.minimum(s, t + 1) << std::endl;
        }
    }
}