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<iostream>
#include<vector>

using std::cin;
using std::cout;
using std::endl;

// Range Minimum, Range Update
template<class T>
struct lazy_segment_tree{
  std::vector<T> data,lazy;
  T identity1,identity2;
  int n;
  lazy_segment_tree(){}
  lazy_segment_tree(int sz,T ide1,T ide2):identity1(ide1),identity2(ide2){
    n = 1;
    while(n<sz)n<<=1;
    data.resize(2*n-1,identity1);
    lazy.resize(2*n-1,identity2);
  }
  void eval(int k){
    if(lazy[k]==identity2)return;
    if(k<n-1){
      lazy[2*k+1] = lazy[k];
      lazy[2*k+2] = lazy[k];
    }
    data[k] = lazy[k];
    lazy[k] = identity2;
  }
  void update_impl(int a,int b,T x,int k,int l,int r){
    eval(k);
    if(a<=l&&r<=b){
      lazy[k] = x;
      eval(k);
    }
    else if(a<r&&l<b){
      update_impl(a,b,x,2*k+1,l,(l+r)/2);
      update_impl(a,b,x,2*k+2,(l+r)/2,r);
      data[k] = std::min(data[2*k+1],data[2*k+2]);
    }
  }
  T query_impl(int a,int b,int k,int l,int r){
    eval(k);
    if(r<=a||b<=l){
      return identity1;
    }
    if(a<=l&&r<=b){
      return data[k];
    }
    else{
      T vl = query_impl(a,b,2*k+1,l,(l+r)/2);
      T vr = query_impl(a,b,2*k+2,(l+r)/2,r);
      return std::min(vl,vr);
    }
  }
  void update(int a,int b,T x){
    update_impl(a,b,x,0,0,n);
  }
  T query(int a,int b){
    return query_impl(a,b,0,0,n);
  }
  T operator[](int i){
    return query_impl(i,i+1,0,0,n);
  }
};

signed main(){
  int n,q;
  cin>>n>>q;
  constexpr int64_t INF = (1LL<<31)-1;
  lazy_segment_tree<int64_t> data(n,INF,-1);
  while(q--){
    int c;cin>>c;
    if(c==0){
      int s,t,x;cin>>s>>t>>x;
      data.update(s,t+1,x);
    }else{
      int s,t;cin>>s>>t;
      cout<< data.query(s,t+1) <<endl;
    }
  }
}