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;
const int maxn=400005;

struct node {
	int mn=0x7fffffff,lazy=-1;	
} S[maxn];
int n,q;

void update(int id,int ql,int qr,int v,int l,int r) {
	if (ql==l && qr==r) {
		S[id].lazy=v;
		return;
	}
	if (S[id].lazy!=-1) {
		S[id].mn=S[id].lazy;
		if (l!=r) S[id<<1].lazy=S[id<<1|1].lazy=S[id].lazy;
		S[id].lazy=-1;
	}
	int m=l+r>>1;
	if (qr<=m) update(id<<1,ql,qr,v,l,m);
	else if (ql>m) update(id<<1|1,ql,qr,v,m+1,r);
	else update(id<<1,ql,m,v,l,m), update(id<<1|1,m+1,qr,v,m+1,r);
	int lm=S[id<<1].lazy!=-1?S[id<<1].lazy:S[id<<1].mn;
	int rm=S[id<<1|1].lazy!=-1?S[id<<1|1].lazy:S[id<<1|1].mn;
	S[id].mn=min(lm,rm);
}

int query(int id,int ql,int qr,int l,int r) {
	if (S[id].lazy!=-1) {
		S[id].mn=S[id].lazy;
		if (l!=r) S[id<<1].lazy=S[id<<1|1].lazy=S[id].lazy;
		S[id].lazy=-1;
	}
	if (ql==l && qr==r) return S[id].mn;
	int m=l+r>>1;
	if (qr<=m) return query(id<<1,ql,qr,l,m);
	else if (ql>m) return query(id<<1|1,ql,qr,m+1,r);
	else return min(query(id<<1,ql,m,l,m),query(id<<1|1,m+1,qr,m+1,r));
}

int main() {
	cin>>n>>q;
	for (int i=0;i<q;i++) {
		bool op; cin>>op;
		int s,t,x;
		if (op) {
			cin>>s>>t;
			cout<<query(1,s,t,0,n-1)<<'\n';
		}
		else {
			cin>>s>>t>>x;
			update(1,s,t,x,0,n-1);
		}
	}
}