Problem: 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 l1, r1, l2, r2 — boundaries of two non-intersecting segments. After that he swaps one random element from the [l1, r1] segment with another random element from the [l2, r2] 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.

Input

The first line contains two integers n, q (2 ≤ n ≤ 105, 1 ≤ q ≤ 105) — the number of elements in the array and the number of queries you need to handle.

The second line contains n integers ai (1 ≤ ai ≤ 109) — 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, l1, r1, l2, r2 (1 ≤ l1 ≤ r1 ≤ n, 1 ≤ l2 ≤ r2 ≤ 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 [l1, r1], [l2, r2] don't have common elements. 

Output

For each type 2 query print one real number — the mathematical expectation of the sum of elements in the segment.

Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 4 — formally, the answer is correct if <image> where x is jury's answer and y is yours.

Examples

Input

4 4
1 1 2 2
1 2 2 3 3
2 1 2
1 1 2 3 4
2 1 2


Output

3.0000000
3.0000000


Input

10 5
1 1 1 1 1 2 2 2 2 2
1 1 5 6 10
2 1 5
1 1 5 6 10
1 1 5 6 10
2 6 10


Output

6.0000000
8.0400000


Input

10 10
1 2 3 4 5 6 7 8 9 10
1 1 5 6 10
1 1 5 6 10
2 1 5
1 1 3 6 9
2 1 3
1 5 7 8 10
1 1 1 10 10
2 1 5
2 7 10
2 1 10


Output

23.0000000
14.0000000
28.0133333
21.5733333
55.0000000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
char *p1, *p2;
;
char buffer[100005];
template <class T>
void read(T& x) {
  char ch = ((p1 == p2 &&
              (p2 = (p1 = buffer) + fread(buffer, 1, 100005, stdin), p1 == p2))
                 ? EOF
                 : *p1++);
  x = 0;
  while (!('0' <= ch && ch <= '9'))
    ch = ((p1 == p2 &&
           (p2 = (p1 = buffer) + fread(buffer, 1, 100005, stdin), p1 == p2))
              ? EOF
              : *p1++);
  while ('0' <= ch && ch <= '9')
    x = (x << 1) + (x << 3) + ch - '0',
    ch = ((p1 == p2 &&
           (p2 = (p1 = buffer) + fread(buffer, 1, 100005, stdin), p1 == p2))
              ? EOF
              : *p1++);
}
int n, m;
int a[100005];
double sum[100005 << 2];
double add[100005 << 2];
double mul[100005 << 2];
int qx, qy;
double qd;
void pushdown(int l, int r, int o) {
  if (l == r) return;
  if (mul[o] != 1) {
    mul[o << 1] *= mul[o], mul[o << 1 | 1] *= mul[o];
    sum[o << 1] *= mul[o], sum[o << 1 | 1] *= mul[o];
    add[o << 1] *= mul[o], add[o << 1 | 1] *= mul[o];
    mul[o] = 1;
  }
  if (add[o] != 0) {
    int mid = ((r - l) >> 1) + l;
    add[o << 1] += add[o], add[o << 1 | 1] += add[o];
    sum[o << 1] += (mid + 1 - l) * add[o],
        sum[o << 1 | 1] += (r - mid) * add[o];
    add[o] = 0;
  }
}
void pushup(int l, int r, int o) {
  if (l == r) return;
  sum[o] = sum[o << 1] + sum[o << 1 | 1];
}
void init(int l, int r, int o) {
  mul[o] = 1;
  if (l == r) {
    sum[o] = a[l];
    return;
  }
  int mid = ((r - l) >> 1) + l;
  init(l, mid, o << 1);
  init(mid + 1, r, o << 1 | 1);
  pushup(l, r, o);
}
void Mul(int l, int r, int o) {
  pushdown(l, r, o);
  if (qx <= l && r <= qy) {
    mul[o] *= qd;
    add[o] *= qd;
    sum[o] *= qd;
    return;
  }
  int mid = ((r - l) >> 1) + l;
  if (qx <= mid) Mul(l, mid, o << 1);
  if (qy > mid) Mul(mid + 1, r, o << 1 | 1);
  pushup(l, r, o);
}
void Add(int l, int r, int o) {
  pushdown(l, r, o);
  if (qx <= l && r <= qy) {
    add[o] += qd;
    sum[o] += (r - l + 1) * qd;
    return;
  }
  int mid = ((r - l) >> 1) + l;
  if (qx <= mid) Add(l, mid, o << 1);
  if (qy > mid) Add(mid + 1, r, o << 1 | 1);
  pushup(l, r, o);
}
double get(int l, int r, int o) {
  pushdown(l, r, o);
  if (qx <= l && r <= qy) return sum[o];
  int mid = ((r - l) >> 1) + l;
  double ans = 0;
  if (qx <= mid) ans += get(l, mid, o << 1);
  if (qy > mid) ans += get(mid + 1, r, o << 1 | 1);
  return ans;
}
int main() {
  read(n), read(m);
  for (register int i = 1; i <= n; i++) read(a[i]);
  init(1, n, 1);
  int op, x, y, z, w;
  for (register int i = 1; i <= m; i++) {
    read(op);
    if (op == 1) {
      read(x), read(y), read(z), read(w);
      int l1 = y - x + 1;
      int l2 = w - z + 1;
      qx = x, qy = y;
      double s1 = get(1, n, 1);
      qd = 1.0 * (l1 - 1) / l1;
      Mul(1, n, 1);
      qx = z, qy = w;
      double s2 = get(1, n, 1);
      qd = 1.0 * (l2 - 1) / l2;
      Mul(1, n, 1);
      qx = x, qy = y, qd = 1.0 / l1 * (1.0 * s2 / l2);
      Add(1, n, 1);
      qx = z, qy = w, qd = 1.0 / l2 * (1.0 * s1 / l1);
      Add(1, n, 1);
    } else if (op == 2) {
      read(qx), read(qy);
      printf("%.7lf\n", get(1, n, 1));
    } else
      printf("fu*k!\n");
  }
  return 0;
}