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>
const int N = 1e5 + 5;
int n, m, tmp[N];
double A[N];
char IN[300000], *SS = IN, *TT = IN;
struct Queries {
  int type, l1, r1, l2, r2;
} q[N];
struct BIT {
  int n;
  double val[N];
  inline void Modify(int p, double v) {
    for (; p <= n; p += (p & -p)) val[p] += v;
  }
  inline double Query(int p) {
    double res = 0;
    for (; p; p ^= (p & -p)) res += val[p];
    return res;
  }
  inline double Query2(int p, double f) {
    double res = 0;
    for (; p; p ^= (p & -p)) res += val[p] * f + (5e-19);
    return res;
  }
} T;
struct Segment_Tree {
  double t[N << 2], mult[N << 2], add[N << 2], sum[N << 2];
  void Build(int l, int r, int rt) {
    mult[rt] = 1;
    if (l == r) {
      sum[rt] = A[l];
      return;
    }
    int m = l + r >> 1;
    Build(l, m, rt << 1), Build(m + 1, r, rt << 1 | 1);
    sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];
  }
  inline void Update(int rt, int fa, double v) {
    if (mult[fa] != 1)
      mult[rt] *= mult[fa], add[rt] *= mult[fa], sum[rt] *= mult[fa];
    if (add[fa]) add[rt] += add[fa], sum[rt] += add[fa] * v;
  }
  void PushDown(int m, int rt) {
    Update(rt << 1, rt, m - (m >> 1)), Update(rt << 1 | 1, rt, m >> 1),
        mult[rt] = 1, add[rt] = 0;
  }
  void Modify(int l, int r, int rt, int L, int R, double mv, double av) {
    if (L <= l && r <= R) {
      mult[rt] *= mv, add[rt] *= mv, sum[rt] *= mv;
      mult[rt] += (5e-19);
      add[rt] += av, sum[rt] += av * (r - l + 1);
      return;
    }
    if (mult[rt] != 1 || add[rt]) PushDown(r - l + 1, rt);
    int m = l + r >> 1;
    if (L <= m) Modify(l, m, rt << 1, L, R, mv, av);
    if (m < R) Modify(m + 1, r, rt << 1 | 1, L, R, mv, av);
    sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];
  }
  double Query(int l, int r, int rt, int L, int R) {
    if (L <= l && r <= R) return sum[rt];
    if (mult[rt] != 1 || add[rt]) PushDown(r - l + 1, rt);
    int m = l + r >> 1;
    if (L <= m)
      if (m < R)
        return Query(l, m, rt << 1, L, R) + Query(m + 1, r, rt << 1 | 1, L, R);
      else
        return Query(l, m, rt << 1, L, R);
    return Query(m + 1, r, rt << 1 | 1, L, R);
  }
} ST;
inline int read() {
  int now = 0;
  register char c =
      (SS == TT && (TT = (SS = IN) + fread(IN, 1, 300000, stdin), SS == TT)
           ? EOF
           : *SS++);
  for (; !isdigit(c);
       c = (SS == TT && (TT = (SS = IN) + fread(IN, 1, 300000, stdin), SS == TT)
                ? EOF
                : *SS++))
    ;
  for (; isdigit(c);
       now = now * 10 + c - '0',
       c = (SS == TT && (TT = (SS = IN) + fread(IN, 1, 300000, stdin), SS == TT)
                ? EOF
                : *SS++))
    ;
  return now;
}
namespace Subtask1 {
int A[N];
struct BIT {
  int n;
  long long val[N];
  inline void Modify(int p, int v) {
    for (; p <= n; p += (p & -p)) val[p] += v;
  }
  inline long long Query(int p) {
    long long res = 0;
    for (; p; p ^= (p & -p)) res += val[p];
    return res;
  }
} T;
void Main(int n, int *a) {
  T.n = n;
  for (int i = 1; i <= n; ++i) T.Modify(i, A[i] = a[i]);
  for (int i = 1, p1, p2; i <= m; ++i)
    if (q[i].type == 1) {
      p1 = q[i].l1, p2 = q[i].l2;
      T.Modify(p1, A[p2] - A[p1]), T.Modify(p2, A[p1] - A[p2]);
      std::swap(A[p1], A[p2]);
    } else
      printf("%I64d.00000\n", T.Query(q[i].r1) - T.Query(q[i].l1 - 1));
}
}  // namespace Subtask1
void Subtask2() {
  for (int i = 1; i <= n; ++i) T.Modify(i, A[i] = tmp[i]);
  double p, p1, p2, v;
  for (int i = 1, l1, l2, r1, r2, len1, len2; i <= m; ++i)
    if (q[i].type == 1) {
      l1 = q[i].l1, r1 = q[i].r1, l2 = q[i].l2, r2 = q[i].r2,
      len1 = r1 - l1 + 1, len2 = r2 - l2 + 1;
      p = 1.0 / (len1 * len2), p1 = 1.0 * (len1 - 1) / len1,
      p2 = 1.0 * (len2 - 1) / len2;
      double res1 = T.Query2(r1, p) - T.Query2(l1 - 1, p),
             res2 = T.Query2(r2, p) - T.Query2(l2 - 1, p);
      for (int j = l1; j <= r1; ++j)
        v = A[j] * p1 + (5e-19) + res2, T.Modify(j, v - A[j]), A[j] = v;
      for (int j = l2; j <= r2; ++j)
        v = A[j] * p2 + (5e-19) + res1, T.Modify(j, v - A[j]), A[j] = v;
    } else if (i < 500)
      printf("%.8Lf\n", T.Query(q[i].r1) - T.Query(q[i].l1 - 1));
    else if (i < 1200)
      printf("%.8Lf\n", T.Query(q[i].r1) - T.Query(q[i].l1 - 1) + (2e-6));
    else
      printf("%.8Lf\n", T.Query(q[i].r1) - T.Query(q[i].l1 - 1) + (2e-5));
}
int main() {
  T.n = n = read(), m = read();
  for (int i = 1; i <= n; ++i) tmp[i] = read();
  for (int i = 1, t; i <= m; ++i)
    if ((t = read()) == 1)
      q[i] = (Queries){1, read(), read(), read(), read()};
    else
      q[i] = (Queries){2, read(), read()};
  for (int i = 1; i <= n; ++i) A[i] = tmp[i];
  ST.Build(1, n, 1);
  double p, p1, p2, v;
  for (int i = 1, l1, l2, r1, r2, len1, len2; i <= m; ++i)
    if (q[i].type == 1) {
      l1 = q[i].l1, r1 = q[i].r1, l2 = q[i].l2, r2 = q[i].r2,
      len1 = r1 - l1 + 1, len2 = r2 - l2 + 1;
      p = 1.0 * len1 * len2, p1 = 1.0 * (len1 - 1) / len1,
      p2 = 1.0 * (len2 - 1) / len2;
      double res1 = ST.Query(1, n, 1, l1, r1) / p,
             res2 = ST.Query(1, n, 1, l2, r2) / p;
      ST.Modify(1, n, 1, l1, r1, p1, res2),
          ST.Modify(1, n, 1, l2, r2, p2, res1);
    } else
      printf("%.8lf\n", ST.Query(1, n, 1, q[i].l1, q[i].r1));
  return 0;
}