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;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
inline void gn(long long &first) {
  int sg = 1;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  c == '-' ? (sg = -1, first = 0) : (first = c - '0');
  while ((c = getchar()) >= '0' && c <= '9') first = first * 10 + c - '0';
  first *= sg;
}
inline void gn(int &first) {
  long long t;
  gn(t);
  first = t;
}
inline void gn(unsigned long long &first) {
  long long t;
  gn(t);
  first = t;
}
inline void gn(double &first) {
  double t;
  scanf("%lf", &t);
  first = t;
}
inline void gn(long double &first) {
  double t;
  scanf("%lf", &t);
  first = t;
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int N, Q, a[200010];
struct Node {
  int st, ed;
  double sum, fm, fs;
} Mem[200010 * 3];
void push_up(int u) {
  Mem[u].sum = Mem[(u << 1)].sum + Mem[((u << 1) + 1)].sum;
}
void build(int u, int st, int ed) {
  Mem[u].st = st;
  Mem[u].ed = ed;
  Mem[u].fm = 1;
  Mem[u].fs = 0;
  if (st + 1 == ed) {
    Mem[u].sum = a[st];
    return;
  }
  build((u << 1), st, (st + ed >> 1));
  build(((u << 1) + 1), (st + ed >> 1), ed);
  push_up(u);
}
void push_down(int u) {
  int st = Mem[u].st, ed = Mem[u].ed;
  Mem[(u << 1)].fm *= Mem[u].fm;
  Mem[(u << 1)].fs = Mem[(u << 1)].fs * Mem[u].fm + Mem[u].fs;
  Mem[(u << 1)].sum =
      Mem[(u << 1)].sum * Mem[u].fm + Mem[u].fs * ((st + ed >> 1) - st);
  Mem[((u << 1) + 1)].fm *= Mem[u].fm;
  Mem[((u << 1) + 1)].fs = Mem[((u << 1) + 1)].fs * Mem[u].fm + Mem[u].fs;
  Mem[((u << 1) + 1)].sum =
      Mem[((u << 1) + 1)].sum * Mem[u].fm + Mem[u].fs * (ed - (st + ed >> 1));
  Mem[u].fm = 1;
  Mem[u].fs = 0;
}
void update(int u, int st, int ed, double m, double s) {
  st = max(Mem[u].st, st);
  ed = min(Mem[u].ed, ed);
  if (st >= ed) return;
  if (st == Mem[u].st && ed == Mem[u].ed) {
    Mem[u].fm *= m;
    Mem[u].fs = Mem[u].fs * m + s;
    Mem[u].sum = s * (ed - st) + Mem[u].sum * m;
    return;
  }
  push_down(u);
  update((u << 1), st, ed, m, s);
  update(((u << 1) + 1), st, ed, m, s);
  push_up(u);
}
double calc(int u, int st, int ed) {
  st = max(Mem[u].st, st);
  ed = min(Mem[u].ed, ed);
  if (st >= ed) return 0;
  if (st == Mem[u].st && ed == Mem[u].ed) {
    return Mem[u].sum;
  }
  push_down(u);
  return calc((u << 1), st, ed) + calc(((u << 1) + 1), st, ed);
}
int main() {
  int l, r, l_, r_, t;
  gn(N);
  gn(Q);
  for (int i = 0; i < N; i++) gn(a[i]);
  build(1, 0, N);
  while (Q--) {
    gn(t);
    if (t == 1) {
      gn(l);
      gn(r);
      gn(l_);
      gn(r_);
      l--;
      l_--;
      double s1 = calc(1, l, r);
      double s2 = calc(1, l_, r_);
      int L1 = r - l, L2 = r_ - l_;
      update(1, l, r, 1.0 * (L1 - 1) / L1, s2 / (1.0 * L1 * L2));
      update(1, l_, r_, 1.0 * (L2 - 1) / L2, s1 / (1.0 * L1 * L2));
    } else {
      gn(l);
      gn(r);
      l--;
      printf("%.10lf\n", calc(1, l, r));
    }
  }
  return 0;
}