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 <class T, class U>
struct LazyST {
  int n;
  int stOffset;
  int stHi;
  vector<T> st;
  vector<U> lazy;
  LazyST(const int n) : n(n) {
    stOffset = 1 << (int)ceil(log2(n));
    st.resize(stOffset << 1);
    lazy.resize(st.size());
    stHi = st.size() - 1 - stOffset;
  }
  LazyST(const int n, istream &in) : LazyST(n) {
    for (int i = 0; i < n; ++i) in >> st[i + stOffset].v;
    for (int si = stOffset - 1; si; --si)
      st[si] = T(st[si << 1], st[si << 1 | 1]);
  }
  void updateLazy(const int si, const int lo, const int hi) {
    lazy[si].apply(st[si], lo, hi);
    if (lo != hi) {
      lazy[si << 1] = U(lazy[si << 1], lazy[si]);
      lazy[si << 1 | 1] = U(lazy[si << 1 | 1], lazy[si]);
    }
    lazy[si] = U();
  }
  T query(const int i, const int j, const int si, const int lo, const int hi) {
    updateLazy(si, lo, hi);
    if (i <= lo && hi <= j) return st[si];
    auto mid = (lo + hi) >> 1;
    if (j <= mid) return query(i, j, si << 1, lo, mid);
    if (mid < i) return query(i, j, si << 1 | 1, mid + 1, hi);
    return T(query(i, j, si << 1, lo, mid),
             query(i, j, si << 1 | 1, mid + 1, hi));
  }
  T query(const int i, const int j) {
    return (i <= j && i < n && j >= 0) ? query(i, j, 1, 0, stHi) : T();
  }
  void update(const int i, const int j, const U &u, const int si, const int lo,
              const int hi) {
    if (i <= lo && hi <= j) {
      lazy[si] = U(lazy[si], u);
      updateLazy(si, lo, hi);
    } else {
      updateLazy(si, lo, hi);
      if (hi < i || j < lo) return;
      int mid = (lo + hi) >> 1;
      update(i, j, u, si << 1, lo, mid);
      update(i, j, u, si << 1 | 1, mid + 1, hi);
      st[si] = T(st[si << 1], st[si << 1 | 1]);
    }
  }
  void update(const int i, const int j, const U u) {
    if (i <= j) update(i, j, u, 1, 0, stHi);
  }
  void remAll(const int i, const int j, const int si, const int lo,
              const int hi, vector<int> &res) {
    updateLazy(si, lo, hi);
    if (!st[si] || hi < i || j < lo) return;
    if (lo == hi) {
      res.push_back(si - stOffset);
      st[si] = 0;
    } else {
      int mid = (lo + hi) >> 1;
      remAll(i, j, si << 1, lo, mid, res);
      remAll(i, j, si << 1 | 1, mid + 1, hi, res);
      st[si] = T(st[si << 1], st[si << 1 | 1]);
    }
  }
  vector<int> remAll(const int i, const int j) {
    vector<int> res;
    remAll(i, j, 1, 0, stHi, res);
    return res;
  }
  void updateAllLazy(const int si, const int lo, const int hi) {
    updateLazy(si, lo, hi);
    if (lo != hi) {
      int mid = (lo + hi) >> 1;
      updateAllLazy(si >> 1, lo, mid);
      updateAllLazy(si >> 1 | 1, mid + 1, hi);
    }
  }
  void updateAllLazy() { updateAllLazy(1, 0, stHi); }
  const T *const retreive() {
    updateAllLazy();
    return &st[stOffset];
  }
  vector<T> retreiveVector() {
    updateAllLazy();
    return vector<T>(&st[stOffset], &st[stOffset + n]);
  }
};
struct StVal {
  double v = 0;
  StVal() {}
  StVal(const double v) : v(v) {}
  StVal(const StVal &v1, const StVal &v2) { v = v1 + v2; }
  operator double() const { return v; }
};
struct StUpdate {
  double a = 1, b = 0;
  StUpdate() {}
  StUpdate(const double a, const double b) : a(a), b(b) {}
  StUpdate(const StUpdate &u1, const StUpdate &u2) {
    a = u1.a * u2.a;
    b = u2.a * u1.b + u2.b;
  }
  void apply(StVal &v, const int lo, const int hi) {
    v.v = a * v.v + b * (hi - lo + 1);
  }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  cin >> n >> q;
  LazyST<StVal, StUpdate> st(n, cin);
  while (q-- > 0) {
    int type;
    cin >> type;
    if (type == 2) {
      int l, r;
      cin >> l >> r;
      cout << st.query(--l, --r) << '\n';
    } else {
      int l1, r1, l2, r2;
      cin >> l1 >> r1 >> l2 >> r2;
      double q1 = st.query(--l1, --r1);
      double q2 = st.query(--l2, --r2);
      double a1 = (double)(r1 - l1) / (r1 - l1 + 1);
      double a2 = (double)(r2 - l2) / (r2 - l2 + 1);
      double b1 = (1 - a1) * q2 / (r2 - l2 + 1);
      double b2 = (1 - a2) * q1 / (r1 - l1 + 1);
      st.update(l1, r1, {a1, b1});
      st.update(l2, r2, {a2, b2});
    }
  }
  return 0;
}