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 <bits/stdc++.h>
using namespace std;

#define int long long
const int INF = (1LL << 31) - 1;
const int MAX_N = 100001;

struct Node {
  int type;
  int value;
  Node(int a, int b) { type = a; value = b; }
};

struct LazySegTree {
  int n;
  vector<Node> lazy;
  vector<int> tree;

  LazySegTree(int n_) {
    n = 1;
    while ( n < n_ ) n <<= 1;
    tree = vector<int>(2 * n - 1, INF);
    lazy = vector<Node>(2 * n - 1, Node(0, INF));
  }

  void propagate(int k, int l, int r) {
    Node p = lazy[k];
    lazy[k].type = 0;
    if ( p.type == 0 || r - l == 1 ) return;
    lazy[k * 2 + 1] = lazy[k * 2 + 2] = p;
    tree[k * 2 + 1] = tree[k * 2 + 2] = p.value;
  }

  void update(int a, int b, int x) { update(a, b, x, 0, 0, n); }
  void update(int a, int b, int x, int k, int l, int r) {
    if ( b <= l || r <= a ) return;
    propagate(k, l, r);
    if ( a <= l && r <= b ) {
      lazy[k] = Node(1, x);
      tree[k] = x;
    } else {
      int mid = (l + r) / 2;
      update(a, b, x, k * 2 + 1, l, mid);
      update(a, b, x, k * 2 + 2, mid, r);
      tree[k] = min(tree[k * 2 + 1], tree[k * 2 + 2]);
    }
  }

  int get_min(int a, int b) { return get_min(a, b, 0, 0, n); }
  int get_min(int a, int b, int k, int l, int r) {
    if ( b <= l || r <= a ) return (1LL << 60);
    propagate(k, l, r);
    if ( a <= l && r <= b ) {
      return tree[k];
    } else {
      int mid = (l + r) / 2;
      int l_value = get_min(a, b, k * 2 + 1, l, mid);
      int r_value = get_min(a, b, k * 2 + 2, mid, r);
      return min(l_value, r_value);
    }
  }
};

signed main() {
  int n, q;
  cin >> n >> q;

  LazySegTree tree(n);
  while ( q-- ) {
    int type, a, b, x;
    cin >> type;
    if ( type ) {
      cin >> a >> b;
      cout << tree.get_min(a, b + 1) << endl;
    } else {
      cin >> a >> b >> x;
      tree.update(a, b + 1, x);
    }
  }

  return 0;
}