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>
using namespace std;

#define INF (1 << 30) - 1 + (1 << 30)

int a[262144], n2, lazy[262144];

void lazyeval(int i) {
  if (lazy[i] == INF) return;
  a[i] = lazy[i];
  if (i < n2 - 1) {
    lazy[2 * i + 1] = lazy[2 * i + 2] = lazy[i];
  }
  lazy[i] = INF;
}
int find(int s, int t, int i, int l, int r) {
    lazyeval(i);
  if (s <= l && r <= t) return a[i];
  if (t <= l || r <= s) return INF;
  int cl, cr;
  cl = find(s, t, i * 2 + 1, l, (l + r) / 2);
  cr = find(s, t, i * 2 + 2, (l + r) / 2, r);
  return min(cl, cr);
}

// int findsingle(int i) {
//   int j = i + n2 - 1;
//   int val = a[i + n2 - 1];
//   if (lazy[j] != INF) val = lazy[j];
//   while (j > 0) {
//     j = (j - 1) / 2;
//     if (lazy[j] != INF) val = lazy[j];
//   }

//   return val;
// }

void updaterange(int s, int t, int i, int l, int r, int x) {
  lazyeval(i);
  // cout << s << " " << t << " " << i << " " << l << " " << r << endl;
  if (s <= l && r <= t) {
    a[i] = x;
    if (i < n2 - 1) {
      lazy[2 * i + 1] = lazy[2 * i + 2] = a[i];
    }
    return;
  }
  if (t <= l || r <= s) return;
  updaterange(s, t, i * 2 + 1, l, (l + r) / 2, x);
  updaterange(s, t, i * 2 + 2, (l + r) / 2, r, x);

  a[i] = min(a[i * 2 + 1], a[i * 2 + 2]);
}

int main() {
  int n, q, com, s, t, x;

  cin >> n >> q;
  n2 = 1;
  while (n > n2) n2 *= 2;
  for (int i = 0; i < n2 * 2; i++) a[i] = lazy[i] = INF;

  for (int i = 0; i < q; i++) {
    cin >> com >> s>>t;
    if (com == 0) {
      cin >> x;
      updaterange(s, t + 1, 0, 0, n2, x);
    } else
      cout << find(s,t + 1, 0, 0, n2) << endl;
  }
  return 0;
}