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 <climits>

struct Node {
	int key;
	int lazy;
	Node() {}
};

void eval(Node* segtree, int index, int l, int r)
{
	if (segtree[index].lazy < INT_MAX) {
		segtree[index].key = segtree[index].lazy;
		if (l+1 < r) {
			segtree[2*index+1].lazy = segtree[index].lazy;
			segtree[2*index+2].lazy = segtree[index].lazy;
		}
		segtree[index].lazy = INT_MAX;
	}
}

void update(Node* segtree, int s, int t, int x, int l, int r, int index, int time)
{
	eval(segtree, index, l, r);
	
	if (t<l || r<=s) return;
	else if (s<=l && r<=t+1) {
		//segtree[index].key = x;
		segtree[index].lazy = x;
		eval(segtree, index, l, r);
	}
	else {
		int mid = (l + r) / 2;
		update(segtree, s, t, x, l, mid, 2*index+1, time);
		update(segtree, s, t, x, mid, r, 2*index+2, time);
		segtree[index].key = std::min(segtree[2*index+1].key, segtree[2*index+2].key);
	}
}

int find(Node* segtree, int s, int t, int l, int r, int index)
{
	if (t<l || r<=s) return INT_MAX;
	
	eval(segtree, index, l, r);
	
	if (s<=l && r<=t+1) {
		return segtree[index].key;
	}
	else {
		int mid = (l + r) / 2;
		int x = find(segtree, s, t, l, mid, 2*index+1);
		int y = find(segtree, s, t, mid, r, 2*index+2);
		return std::min(x, y);
	}
}

int main()
{
	int n; std::cin >> n;
	int seg_size = 1;
	for (; seg_size < n; seg_size<<=1);
	Node* segtree = new Node[2*seg_size-1];
	for (int i=0; i<2*seg_size-1; i++) {
		segtree[i].key = INT_MAX;
		segtree[i].lazy = INT_MAX;
	}
	
	int q; std::cin >> q;
	for (int i=0; i<q; i++) {
		int op, s, t, x;
		std::cin >> op;
		if (op==0) {
			std::cin >> s >> t >> x;
			update(segtree, s, t, x, 0, seg_size, 0, i);
		}
		else {
			std::cin >> s >> t;
			std::cout << find(segtree, s, t, 0, seg_size, 0) << std::endl;
		}
	}
	delete[] segtree;
	return 0;
}