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 <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

class LazySegmentTree{
public:
  int N;
  vector<ll> node, lazy;
  ll INF = 1LL << 40;

  //コンストラクタ
  LazySegmentTree(vector<ll> v){
    int sz = v.size();
    N = 1;
    while(N < sz) N *= 2;
    node.resize(2 * N - 1, INF);
    lazy.resize(2 * N - 1, INF);

    for(int i = 0; i < sz; i++){
      int k = i + N - 1;
      node[k] = v[i];
      while(k > 0){
        k = (k - 1) / 2;
        node[k] = min(node[k * 2 + 1], node[k * 2 + 2]);
      }
    }
  }

  // [a, b)をcに変更
  void update(int a, int b, ll c){
    Update(a, b, c, 0, 0, N);
  }

  void Update(int a, int b, ll c, int k, int l, int r){
    eval(k, l, r);
    if(r <= a || b <= l) return;
    if(a <= l && r <= b){
      lazy[k] = c;
      eval(k, l, r);
    }
    else {
      Update(a, b, c, 2 * k + 1, l, (l + r) / 2);
      Update(a, b, c, 2 * k + 2, (l + r) / 2, r);
      node[k] = min(node[2 * k + 1], node[2 * k + 2]);
    }
  }

  //[a,b)の最小値
  ll query(int a, int b){
    return Query(a, b, 0, 0, N);
  }

  ll Query(int a, int b, int k, int l, int r){
    eval(k, l, r);
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return node[k];
    else{
      ll v1 = Query(a, b, k * 2 + 1, l, (l + r) / 2);
      ll v2 = Query(a, b, k * 2 + 2, (l + r) / 2, r);
      return min(v1, v2);
    }
  }

  //k番目のノードに遅延評価
  void eval(int k, int l, int r){
    if(lazy[k] != INF){
      node[k] = lazy[k];

      //最下段でないなら
      if(r - l > 1){
        lazy[2 * k + 1] = lazy[k];
        lazy[2 * k + 2] = lazy[k];
      }

      //自ノードの遅延配列を0に
      lazy[k] = INF;
    }
  }

  void print(){
    for(int i = 0; i < 2 * N - 1; i++){
      cout << "node[" << i << "] " << node[i] << "  " << lazy[i] << endl;
    }
  }
};

int main(){
  int N, Q;
  cin >> N >> Q;

  vector<ll> a(N, (1LL << 31) - 1);
  LazySegmentTree sg = LazySegmentTree(a);

  vector<ll> ans;

  for(int i = 0; i < Q; i++){
    int j, s, t;
    ll x;
    cin >> j;
    if(j == 0){
      cin >> s >> t >> x;
      sg.update(s, t + 1, x);
    }
    if(j == 1){
      cin >> s >> t;
      ans.push_back(sg.query(s, t + 1));
    }

    //sg.print();
    //cout << endl;
  }

  for(auto it = ans.begin(); it != ans.end(); it++){
    cout << *it << endl;
  }

  return 0;
}