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 <cstdio>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1, 0, 1, 1, -1, -1}, dx = {1,-1,0,0, 0, 1, -1, 1, -1};
//vector<int> dy = {0, 0, 1, -1}, dx = {1, -1, 0, 0};

int N, Q;
int N_ = 1;
const int segSize = (1 << 18) - 1;
vector<ll> Seg(segSize, INT_MAX), lazySeg(segSize);
bool lated[segSize];

void eval(int k, int l, int r){
    if(lated[k]){
        Seg[k] = lazySeg[k];
        if(r - l > 1){
            lazySeg[2*k+1] = lazySeg[k];
            lazySeg[2*k+2] = lazySeg[k];
            lated[2*k+1] = 1;
            lated[2*k+2] = 1;
        }
        lated[k] = 0;
    }
}

void update(int a, int b, int x, int k, int l, int r){
    eval(k, l, r);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b){
        lazySeg[k] = x;
        lated[k] = 1;
        eval(k, l, r);
    }
    else{
        update(a, b, x, 2*k+1, l, (l+r)/2);
        update(a, b, x, 2*k+2, (l+r)/2, r);
        Seg[k] = min(Seg[2*k+1], Seg[2*k+2]);
    }
}

int find(int a, int b, int k, int l, int r){
    eval(k, l, r);
    if(b <= l || r <= a) return INT_MAX;
    if(a <= l && r <= b) return Seg[k];
    return min(find(a, b, 2*k+1, l, (l+r)/2), find(a, b, 2*k+2, (l+r)/2, r));
}


int main(void){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    cin >> N >> Q;
    while(N_ < N) N_ *= 2;
    for(int i = 0; i < 2*N_+1; i++) Seg[i] = 2147483647;
    
    for(int i = 0; i < Q; i++){
        int com; cin >> com;
        if(com == 0){
            int s, t, x; cin >> s >> t >> x;
            update(s, t+1, x, 0, 0, N_);
        }else{
            int s, t; cin >> s >> t;
            cout << find(s, t+1, 0, 0, N_) << endl;
        }
    }
}