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 PYTHON3):

Solution:
class SegmentTree(object):
    INIT = 2 ** 31 - 1
    DIVIDED = -1

    def __init__(self, n: int) -> None:
        size = 1
        while size < n:
            size *= 2
        self.size = 2 * size - 1
        self.data = [-1] * self.size
        self.data[0] = self.INIT

    def set_range(self, l: int, h: int, v: int) -> None:
        def _set_range(r, i: int, j: int, vv: int) -> None:
            if (j < l or i > h):
                if vv != self.DIVIDED:
                    self.data[r] = vv
            elif (l <= i and j <= h):  # noqa: E741
                self.data[r] = v
            else:
                if self.data[r] != self.DIVIDED:
                    if vv == self.DIVIDED:
                        vv = self.data[r]
                    self.data[r] = self.DIVIDED
                mid = i + (j - i) // 2
                _set_range(r * 2 + 1, i, mid, vv)
                _set_range(r * 2 + 2, mid + 1, j, vv)

        _set_range(0, 0, self.size // 2, self.DIVIDED)

    def min(self, i: int, j: int) -> int:
        def _min(r, l: int, h: int) -> int:
            if (j < l or i > h):
                return self.INIT
            elif self.data[r] != self.DIVIDED:
                return self.data[r]
            else:
                mid = l + (h - l) // 2
                return min(_min(r * 2 + 1, l, mid),
                           _min(r * 2 + 2, mid + 1, h))

        return _min(0, 0, self.size // 2)


if __name__ == "__main__":
    n, q = map(lambda x: int(x), input().split())
    segtree = SegmentTree(n)

    for _ in range(q):
        com, *v = map(lambda x: int(x), input().split())
        if (0 == com):
            segtree.set_range(v[0], v[1], v[2])
        else:
            print(segtree.min(v[0], v[1]))