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;

int n, q;

struct Node {
  int min = 0x7fffffff, lazy = -1;
} seg[800005];

void update(int u, int l, int r, int ql, int qr, int v) {
  if (seg[u].lazy != -1) {
    seg[u << 1].lazy =
      seg[u << 1 | 1].lazy =
      seg[u].lazy;
    seg[u].lazy = -1;
  }

  if (l == ql && r == qr) {
    seg[u].lazy = v;
    return;
  }

  int m = (l + r) >> 1;

  if (qr <= m)
    update(u << 1, l, m, ql, qr, v);
  else if (ql > m)
    update(u << 1 | 1, m + 1, r, ql, qr, v);
  else
    update(u << 1, l, m, ql, m, v), update(u << 1 | 1, m + 1, r, m + 1, qr, v);
  
  int lm = seg[u << 1].lazy != -1 ? seg[u << 1].lazy : seg[u << 1].min;
  int rm = seg[u << 1 | 1].lazy != -1 ? seg[u << 1 | 1].lazy : seg[u << 1 | 1].min;

  seg[u].min = min(lm, rm);
}

int query(int u, int l, int r, int ql, int qr) {
  if (seg[u].lazy != -1)
    return seg[u].lazy;

  if (l == ql && r == qr)
    return seg[u].min;  

  int m = (l + r) >> 1;
  if (qr <= m)
    return query(u << 1, l, m, ql, qr);
  else if (ql > m)
    return query(u << 1 | 1, m + 1, r, ql, qr);
  else
    return min(query(u << 1, l, m, ql, m),
        query(u << 1 | 1, m + 1, r, m + 1, qr));
}

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

  for (int i = 0; i < q; i++) {
    int o; cin >> o;
    if (o == 0) {
      // update
      int l, r, v; cin >> l >> r >> v;
      update(1, 0, n - 1, l, r, v);
    } else {
      int l, r; cin >> l >> r;
      cout << query(1, 0, n - 1, l, r) << endl;
    }
  }
}