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 JAVA):

Solution:
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/*
 public class _895E {

 }

 */
public class _895E {

  class LazySegmentTree {
    double[] tree;
    int n;
    double[] a;
    double[] lazyadd;
    double[] lazysub;

    public LazySegmentTree(double[] a, int n) {
      super();
      this.a = a;
      this.n = n;
      this.tree = new double[4 * n];
      this.lazyadd = new double[4 * n];
      this.lazysub = new double[4 * n];
    }

    public double build(int i, int rs, int re) {
      if (rs == re) {
        tree[i] = a[rs];
        return tree[i];
      } else {
        int mid = (rs + re) / 2;

        double left = build(i * 2 + 1, rs, mid);
        double right = build(i * 2 + 2, mid + 1, re);

        tree[i] = (left + right);

        return tree[i];
      }
    }

    public double query(int i, int rs, int re, int qs, int qe) {
      lazyAdjustment(i, rs, re);

      if (re < qs || qe < rs) {
        return 0;
      }

      if (qs <= rs && qe >= re) {
        return tree[i];
      }

      int mid = (rs + re) / 2;

      double p1 = query(i * 2 + 1, rs, mid, qs, qe);
      double p2 = query(i * 2 + 2, mid + 1, re, qs, qe);

      return p1 + p2;
    }

    private void lazyAdjustment(int i, int rs, int re) {
      tree[i] += lazyadd[i] * (re - rs + 1) - lazysub[i] * tree[i];

      if (rs < re) {
        lazyadd[i * 2 + 1] += lazyadd[i] - lazysub[i] * lazyadd[i * 2 + 1];
        lazysub[i * 2 + 1] += lazysub[i] - lazysub[i] * lazysub[i * 2 + 1];

        lazyadd[i * 2 + 2] += lazyadd[i] - lazysub[i] * lazyadd[i * 2 + 2];
        lazysub[i * 2 + 2] += lazysub[i] - lazysub[i] * lazysub[i * 2 + 2];
      }

      lazyadd[i] = 0;
      lazysub[i] = 0;
    }

    public double update(int i, int rs, int re, int us, int ue, double add, double sub) {
      lazyAdjustment(i, rs, re);

      if (re < us || ue < rs) {
        return 0;
      }

      if (us <= rs && ue >= re) {
        lazyadd[i] = add;
        lazysub[i] = sub;
        return (re - rs + 1) * add - sub * tree[i];
      }

      int mid = (rs + re) / 2;

      double p1 = update(i * 2 + 1, rs, mid, us, ue, add, sub);
      double p2 = update(i * 2 + 2, mid + 1, re, us, ue, add, sub);

      tree[i] += (p1 + p2);

      return (p1 + p2);
    }
  }


  public void solve() throws FileNotFoundException {
    InputStream inputStream = System.in;

    InputHelper in = new InputHelper(inputStream);

    // actual solution
    int n = in.readInteger();
    int q = in.readInteger();

    double[] a = new double[n];

    for (int i = 0; i < n; i++) {
      a[i] = in.readInteger();
    }

    LazySegmentTree lst = new LazySegmentTree(a, n);
    lst.build(0, 0, n - 1);

    while (q-- > 0) {
      int t = in.readInteger();

      if (t == 1) {
        int l1 = in.readInteger() - 1;
        int r1 = in.readInteger() - 1;

        int l2 = in.readInteger() - 1;
        int r2 = in.readInteger() - 1;

        int n1 = (r1 - l1 + 1);
        int n2 = (r2 - l2 + 1);

        double pre1 = lst.query(0, 0, n - 1, l1, r1);

        double add1 = pre1 / n1 / n2;
        double sub1 = 1.0 / n2;

        double pre2 = lst.query(0, 0, n - 1, l2, r2);

        double add2 = pre2 / n2 / n1;
        double sub2 = 1.0 / n1;

        lst.update(0, 0, n - 1, l2, r2, add1, sub1);
        lst.update(0, 0, n - 1, l1, r1, add2, sub2);
      } else {
        int l = in.readInteger() - 1;
        int r = in.readInteger() - 1;

        System.out.println(lst.query(0, 0, n - 1, l, r));
      }
    }
    // end here
  }

  public static void main(String[] args) throws FileNotFoundException {
    (new _895E()).solve();
  }

  class InputHelper {
    StringTokenizer tokenizer = null;
    private BufferedReader bufferedReader;

    public InputHelper(InputStream inputStream) {
      InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
      bufferedReader = new BufferedReader(inputStreamReader, 16384);
    }

    public String read() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          String line = bufferedReader.readLine();
          if (line == null) {
            return null;
          }
          tokenizer = new StringTokenizer(line);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      return tokenizer.nextToken();
    }

    public Integer readInteger() {
      return Integer.parseInt(read());
    }

    public Long readLong() {
      return Long.parseLong(read());
    }
  }
}