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;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T>
using vec = vector<T>;
template <typename K, typename V>
using umap = unordered_map<K, V>;
template <typename K>
using uset = unordered_set<K>;
using vi = vec<int>;
using vl = vec<ll>;
using vpi = vec<pii>;
using vpl = vec<pll>;
using int128 = __int128_t;
using uint128 = __uint128_t;
template <typename I>
string intStr(I x) {
  string ret;
  while (x > 0) {
    ret += (x % 10) + '0';
    x /= 10;
  }
  reverse(ret.begin(), ret.end());
  return ret;
}
template <typename T>
inline void maxa(T &st, T v) {
  st = max(st, v);
}
template <typename T>
inline void mina(T &st, T v) {
  st = min(st, v);
}
inline void setprec(ostream &out, int prec) {
  out << setprecision(prec) << fixed;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> iter) {
  out << "[";
  for (auto t : iter) {
    out << t << ", ";
  }
  out << "]";
  return out;
}
template <typename T>
string arrayStr(T *arr, int sz) {
  string ret = "[";
  for (int i = 0; i < sz; i++) {
    ret += to_string(arr[i]) + ", ";
  }
  return ret + "]";
}
template <typename T>
void printArray(T *arr, int sz) {
  for (int i = 0; i < sz; i++) {
    cout << arr[i] << " ";
  }
  cout << "\n";
}
inline void scan() {}
template <typename F, typename... R>
inline void scan(F &f, R &...r) {
  cin >> f;
  scan(r...);
}
template <typename F>
inline void println(F t) {
  cout << t << '\n';
}
template <typename F, typename... R>
inline void println(F f, R... r) {
  cout << f << " ";
  println(r...);
}
inline void print() {}
template <typename F, typename... R>
inline void print(F f, R... r) {
  cout << f;
  print(r...);
}
template <typename F>
inline string __generic_tostring(F f) {
  stringstream ss;
  ss << f;
  return ss.str();
}
template <typename F>
inline string __join_comma(F f) {
  return __generic_tostring(f);
}
template <typename F, typename... R>
string __join_comma(F f, R... r) {
  return __generic_tostring(f) + ", " + __join_comma(r...);
}
using pdd = pair<ld, ld>;
const int MN = 1e5 + 1, B = 320;
const pdd ID = {1, 0};
int N, Q, bid[MN];
ld val[MN];
pdd comb(const pdd f, const pdd g) {
  return {f.first * g.first, g.first * f.second + g.second};
}
ld eval(const pdd f, ld x) { return f.first * x + f.second; }
struct Block {
  int l, r;
  ld sum;
  pdd lazyFun;
  void init() { l = 0x3f3f3f3f, r = 0; }
  void setup() {
    sum = 0;
    lazyFun = ID;
    for (__typeof(l) i = l; i < r + 1; i++) sum += val[i];
  }
  int size() { return r - l + 1; }
  void rebuild(bool force = false) {
    if (!force && lazyFun == ID) return;
    sum = 0;
    for (__typeof(l) i = l; i < r + 1; i++) {
      val[i] = eval(lazyFun, val[i]);
      sum += val[i];
    }
    lazyFun = ID;
  }
};
vec<Block *> bs;
ld query(int L, int R) {
  ld res = 0;
  for (__typeof(bid[L]) i = bid[L]; i < bid[R] + 1; i++) {
    auto *b = bs[i];
    if (L <= b->l && b->r <= R)
      res += b->sum;
    else {
      b->rebuild();
      int st = max(L, b->l), en = min(R, b->r);
      for (__typeof(st) j = st; j < en + 1; j++) res += val[j];
    }
  }
  return res;
}
pdd makeFun(ld n, ld m, ld b, ld sb) { return {1 - 1 / n, b * sb / (n * m)}; }
void upd(int L, int R, int n, int m, ld sb) {
  for (__typeof(bid[L]) i = bid[L]; i < bid[R] + 1; i++) {
    auto *b = bs[i];
    if (L <= b->l && b->r <= R) {
      b->sum = eval(makeFun(n, m, b->size(), sb), b->sum);
      b->lazyFun = comb(b->lazyFun, makeFun(n, m, 1, sb));
    } else {
      b->rebuild();
      int st = max(L, b->l), en = min(R, b->r);
      for (__typeof(st) j = st; j < en + 1; j++)
        val[j] = eval(makeFun(n, m, 1, sb), val[j]);
      b->rebuild(true);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  scan(N, Q);
  for (__typeof(1) i = 1; i < N + 1; i++) {
    scan(val[i]);
    bid[i] = i / B;
    if (bid[i] >= ((int)((bs).size()))) {
      Block *b = new Block;
      b->init();
      b->l = b->r = i;
      bs.push_back(b);
    } else
      bs[bid[i]]->r = i;
  }
  int blockCnt = bid[N];
  for (__typeof(0) i = 0; i < blockCnt + 1; i++) bs[i]->setup();
  while (Q--) {
    int T;
    scan(T);
    if (T == 1) {
      int l1, r1, l2, r2;
      scan(l1, r1, l2, r2);
      int n = r1 - l1 + 1, m = r2 - l2 + 1;
      ld sum1 = query(l1, r1), sum2 = query(l2, r2);
      upd(l1, r1, n, m, sum2);
      upd(l2, r2, m, n, sum1);
    } else {
      int l, r;
      scan(l, r);
      ld ans = query(l, r);
      println(ans);
    }
  }
  return 0;
}