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<stdio.h>
#include<vector>
#include<climits>
#include<math.h>
using namespace std;

int min(const int& a, const int& b){
    return a < b? a : b;
}
int updateUtil(vector<int>& tree, vector<int>& lazy, const int& L, const int& R, const int& v, const int& k, const int& l, const int& r){
    if(k > tree.size() || l > r) return INT_MAX;
    if(lazy[k] >= 0){
        tree[k] = lazy[k];
        if(l < r){
            lazy[2*k+1] = lazy[k];
            lazy[2*k+2] = lazy[k];
        }
        lazy[k] = -1;
    }
    if(l > R || r < L) return tree[k];
    if(l >= L && r <= R){
        tree[k] = v;
        if(l < r){
            lazy[2*k+1] = v;
            lazy[2*k+2] = v;
        }
    }
    else{
        int mid = l+(r-l)/2;
        tree[k] = min(updateUtil(tree, lazy, L, R, v, 2*k+1, l, mid), updateUtil(tree, lazy, L, R, v, 2*k+2, mid+1, r)); 
    }
    return tree[k];
}

void update(vector<int>& tree, vector<int>& lazy, const int& n, const int& L, const int& R, const int& v){
    updateUtil(tree, lazy, L, R, v, 0, 0, n-1);
}

int findUtil(vector<int>& tree, vector<int>& lazy, const int& L, const int& R, const int& k, const int& l, const int& r){
    if(k > tree.size() || l > r) return INT_MAX;
    if(lazy[k] >= 0){
        tree[k] = lazy[k];
        if(l < r){
            lazy[2*k+1] = lazy[k];
            lazy[2*k+2] = lazy[k];
        }
        lazy[k] = -1;
    }
    if(l > R || r < L) return INT_MAX;
    if(l >= L && r <= R) return tree[k];
    int mid = l+(r-l)/2;
    return min(findUtil(tree, lazy, L, R, 2*k+1, l, mid), findUtil(tree, lazy, L, R, 2*k+2, mid+1, r));
}

int find(vector<int>& tree, vector<int>& lazy, const int& n, const int& L, const int& R){
    return findUtil(tree, lazy, L, R, 0, 0, n-1);
}
int main(){
    int n, q, com, s, t, x;
    scanf("%d %d", &n, &q);
    int h = (int)ceil(log2(n));
    int max_size = 2*(int)pow(2, h)-1;
    vector<int> tree(max_size, INT_MAX);
    vector<int> lazy(max_size, -1);
    for(int i = 0; i < q; i++){
        scanf("%d", &com);
        if(com == 0){
            scanf("%d %d %d", &s, &t, &x);
            update(tree, lazy, n, s, t, x);
        }
        else if(com == 1){
            scanf("%d %d", &s, &t);
            printf("%d\n", find(tree, lazy, n, s, t));
        }
        else printf("undefined com\n");
    }    
}