Vasya and Petya were tired of studying so they decided to play a game. Before the game begins Vasya looks at array *a* consisting of *n* integers. As soon as he remembers all elements of *a* the game begins. Vasya closes his eyes and Petya does *q* actions of one of two types:

1) Petya says 4 integers *l*1, *r*1, *l*2, *r*2 — boundaries of two non-intersecting segments. After that he swaps one random element from the [*l*1, *r*1] segment with another random element from the [*l*2, *r*2] segment.

2) Petya asks Vasya the sum of the elements of *a* in the [*l*, *r*] segment.

Vasya is a mathematician so he answers Petya the mathematical expectation of the sum of the elements in the segment.

Your task is to write a program which will answer the second type questions as Vasya would do it. In other words your program should print the mathematical expectation of the sum of the elements of *a* in the [*l*, *r*] segment for every second type query.
The first line contains two integers *n*, *q* (2 ≤ *n* ≤ 10<sup class="upper-index">5</sup>, 1 ≤ *q* ≤ 10<sup class="upper-index">5</sup>)  — the number of elements in the array and the number of queries you need to handle.

The second line contains *n* integers *a*<sub class="lower-index">*i*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>)  — elements of the array.

The next *q* lines contain Petya's actions of type 1 or 2.

If it is a type 1 action then the line contains 5 integers 1, *l*1, *r*1, *l*2, *r*2 (1 ≤ *l*1 ≤ *r*1 ≤ *n*, 1 ≤ *l*2 ≤ *r*2 ≤ *n*).

If it is a type 2 query then the line contains 3 integers 2, *l*, *r* (1 ≤ *l* ≤ *r* ≤ *n*).

It is guaranteed that there is at least one type 2 query and segments [*l*1, *r*1], [*l*2, *r*2] don't have common elements.
none
import sys
input = sys.stdin.readline

def readList():
    return list(map(int, input().split()))
def readInt():
    return int(input())
def readInts():
    return map(int, input().split())
def readStr():
    return input().strip()

class LazySegTree:
    def _update(self, k):
        self.d[k] = self.op(self.d[2 * k], self.d[2 * k + 1])

    def _all_apply(self, k, f):
        self.d[k] = self.mapping(f, self.d[k], self.length[k])
        if k < self.size:
            self.lz[k] = self.composite(f, self.lz[k])

    def _push(self, k):
        self._all_apply(2 * k, self.lz[k])
        self._all_apply(2 * k + 1, self.lz[k])
        self.lz[k] = self.identity

    # customized
    def mapping(self, a, x, l):
        return x if a == -1 else a[0] * x + a[1] * l

    # customized
    def composite(self, a, b):
        if a == self.identity:
            return b
        elif b == self.identity:
            return a
        else:
            return [a[0] * b[0], a[0] * b[1] + a[1]]

    def __init__(self, V, OP, E):
        self.n = len(V)
        self.log = (self.n - 1).bit_length()
        self.size = 1 << self.log
        self.d = [E for i in range(2 * self.size)]
        self.length = [0] * (2 * self.size)
        self.e = E
        self.identity = -1
        self.lz = [-1] * self.size
        # customized
        self.op = OP

        for i in range(self.n):
            self.d[self.size + i] = V[i]
            self.length[self.size + i] = 1
        for i in range(self.size - 1, 0, -1):
            self._update(i)
            self.length[i] = self.length[2 * i] + self.length[2 * i + 1]

    # assign x to point p w/ lazy prop
    def set(self, p, x):
        assert 0 <= p < self.n
        p += self.size
        for i in range(self.log, 0, -1):
            self._push(p >> i)
        self.d[p] = x
        for i in range(1, self.log + 1):
            self._update(p >> i)

    # query point p w/ lazy prop
    def get(self, p):
        assert 0 <= p < self.n
        p += self.size
        for i in range(self.log, 0, -1):
            self._push(p >> i)
        return self.d[p]

    # query range l, r w/ lazy prop
    def prod(self, l, r):
        assert 0 <= l <= r <= self.n
        if l == r:
            return self.e
        l += self.size
        r += self.size
        # lazy prop from the root
        for i in range(self.log, 0, -1):
            if ((l >> i) << i) != l:
                self._push(l >> i)
            if ((r >> i) << i) != r:
                self._push(r >> i)
        sml, smr = self.e, self.e
        while l < r:
            if l & 1:
                sml = self.op(sml, self.d[l])
                l += 1
            if r & 1:
                r -= 1
                smr = self.op(self.d[r], smr)
            l >>= 1
            r >>= 1
        return self.op(sml, smr)

    # query the whole array a[1...n]
    def all_prod(self):
        return self.d[1]

    # update point w/ lazy prop
    def apply_point(self, p, f):
        assert 0 <= p < self.n
        p += self.size
        for i in range(self.log, 0, -1):
            self._push(p >> i)
        self.d[p] = self.mapping(f, self.d[p], self.length[p])
        for i in range(1, self.log + 1):
            self._update(p >> i)

    # update query w/ lazy prop
    def apply(self, l, r, f):
        assert 0 <= l <= r <= self.n
        if l == r:
            return
        l += self.size
        r += self.size
        for i in range(self.log, 0, -1):
            if ((l >> i) << i) != l:
                self._push(l >> i)
            if ((r >> i) << i) != r:
                self._push((r - 1) >> i)
        l2, r2 = l, r
        while l < r:
            if l & 1:
                self._all_apply(l, f)
                l += 1
            if r & 1:
                r -= 1
                self._all_apply(r, f)
            l >>= 1
            r >>= 1
        l, r = l2, r2
        # update from the leaf
        for i in range(1, self.log + 1):
            if ((l >> i) << i) != l:
                self._update(l >> i)
            if ((r >> i) << i) != r:
                self._update((r - 1) >> i)

# BF, EC, DB, CC, CL
def solve():
    n, q = readInts()
    a = readList()
    def add(a, b):
        return a + b
    seg = LazySegTree(a, add, 0)
    for _ in range(q):
        b = readList()
        if b[0] == 1:
            _, l1, r1, l2, r2 = b
            x, y = r1 - l1 + 1, r2 - l2 + 1
            v1, v2 = seg.prod(l1-1, r1) / x, seg.prod(l2-1, r2) / y
            seg.apply(l1-1, r1, [(x-1) / x, v2 / x])
            seg.apply(l2-1, r2, [(y-1) / y, v1 / y])
        else:
            _, l, r = b
            print(seg.prod(l-1, r))
    return

solve()

