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<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<typename X,typename M>
  struct segtree{
    using FX=function<X(X,X)>;
    using FA=function<X(X,M)>;
    using FM=function<M(M,M)>;
    int n;
    FX fx;
    FA fa;
    FM fm;
    const X ex;
    const M em;
    vector<X> dat;
    vector<M> lazy;
    segtree(int n_,FX fx_,FA fa_,FM fm_,X ex_,M em_)
      :n(),fx(fx_),fa(fa_),fm(fm_),ex(ex_),em(em_),dat(n_*4,ex),lazy(n_*4,em){
        int x=1;
        while(n_>x){
          x*=2;
        }
        n=x;
      }
    void set(int i,X x){
      dat[i+n-1]=x;
    }
    void build(){
      for(int k=n-2;k>=0;k--){
        dat[k]=fx(dat[2*k+1],dat[2*k+2]);
      }
    }
    void eval(int k){
      if(lazy[k]==em){
        return;
      }
      if(k<n-1){
        lazy[k*2+1]=fm(lazy[k*2+1],lazy[k]);
        lazy[k*2+2]=fm(lazy[k*2+2],lazy[k]);
      }
      dat[k]=fa(dat[k],lazy[k]);
      lazy[k]=em;
    }
    void update(int a,int b,M x,int k,int l,int r){
      eval(k);
      if(a<=l && r<=b){
        lazy[k]=fm(lazy[k],x);
        eval(k);
      }
      else if(a<r && l<b){
        update(a,b,x,k*2+1,l,(l+r)/2);
        update(a,b,x,k*2+2,(l+r)/2,r);
        dat[k]=fx(dat[k*2+1],dat[k*2+2]);
      }
    }
    void update(int a,int b,M x){
      update(a,b,x,0,0,n);
    }
    X query_sub(int a,int b,int k,int l,int r){
      eval(k);
      if(r<=a  || b<=l){
        return ex;
      }
      else if(a<=l && r<=b){
        return dat[k];
      }
      else{
        X vl=query_sub(a,b,k*2+1,l,(l+r)/2);
        X vr=query_sub(a,b,k*2+2,(l+r)/2,r);
        return fx(vl,vr);
      }
    }
    X query(int a,int b){
      return query_sub(a,b,0,0,n);
    }
  };
int main(){
  using X=long long;
  using M=long long;
  auto fx=[](X x1,X x2) -> X{return min(x1,x2);};
  auto fa=[](X x,M m) -> X{return m;};
  auto fm=[](M m1,M m2) -> M{return m2;};
  long long ex=2147483647;
  long long em=2147483647;
  segtree<X,M> seg(100010,fx,fa,fm,ex,em);
  int n,q;
  cin >> n >> q;
  int a,b,c,i;
  ll d;
  for(i=0;i<q;i++){
    cin >> a;
    if(a==0){
      cin >> b >> c >> d;
      seg.update(b,c+1,d);
    }
    else{
      cin >> b >> c;
      cout << seg.query(b,c+1) << endl;
    }
  }
  return 0;
}