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>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

const int NIL = -1;
const int MAX = 2147483647;
const int N = 100001;
clock_t START, END;
bool debug = false;

int minv[N << 2], addv[N << 2], setv[N << 2];
int ql, qr, p, v;
int _min;

void pushdown(int o)
{
	int lc = o * 2, rc = o * 2 + 1;
	if (setv[o] >= 0) {
		setv[lc] = setv[rc] = setv[o];
		setv[o] = -1;
	}
}

void maintain(int o, int L, int R)
{
	int lc = o * 2, rc = 2 * o + 1;
	if (setv[o] >= 0) {
		minv[o] = setv[o];
	}
	else if (R > L) {
		minv[o] = min(minv[lc], minv[rc]);
	}
	//minv[o] += addv[o];
}

void query(int o, int L, int R)
{
	int M = L + (R - L) / 2;
	if (setv[o] >= 0) {
		_min = min(_min, setv[o]);
	}
	else if (ql <= L && qr >= R) {
		_min = min(_min, minv[o]);
	}
	else {
		if (ql <= M)
			query(o * 2, L, M);
		if (qr > M)
			query(o * 2 + 1, M + 1, R);
	}
}

void update(int o, int L, int R)
{
	int M = L + (R - L) / 2;
	int lc = o * 2, rc = o * 2 + 1;
	if (ql <= L && qr >= R) {
		setv[o] = v;
	}
	else {
		pushdown(o);
		if (ql <= M)
			update(lc, L, M);
		else
			maintain(lc, L, M);
		if (qr > M)
			update(rc, M + 1, R);
		else
			maintain(rc, M + 1, R);
	}
	maintain(o, L, R);
}


int main(void)
{
	if (debug) {
		START = clock();
		freopen("in5.txt", "r", stdin);
		freopen("out1.txt", "w", stdout);
	}
	int n, q, com;
	scanf("%d%d", &n, &q);
	for (int i = 0; i <= 4 * n; i++) {
		setv[i] = -1;
		minv[i] = MAX;
	}
	for (int i = 0; i < q; i++) {
		scanf("%d", &com);
		if (com) {
			scanf("%d%d", &ql, &qr);
			ql++;
			qr++;
			_min = MAX;
			query(1, 1, n);
			printf("%d\n", _min);
		}
		else {
			scanf("%d%d%d", &ql, &qr, &v);
			ql++;
			qr++;
			update(1, 1, n);
		}
	}
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}