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.*;
import java.util.InputMismatchException;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	static class TaskAdapter implements Runnable {
		@Override
		public void run() {
			long startTime = System.currentTimeMillis();
			InputStream inputStream = System.in;
			OutputStream outputStream = System.out;
			FastReader in = new FastReader(inputStream);
			Output out = new Output(outputStream);
			EEyesClosed solver = new EEyesClosed();
			solver.solve(1, in, out);
			out.close();
			System.err.println(System.currentTimeMillis()-startTime+"ms");
		}
	}

	public static void main(String[] args) throws Exception {
		Thread thread = new Thread(null, new TaskAdapter(), "", 1<<26);
		thread.start();
		thread.join();
	}

	static class EEyesClosed {
		public EEyesClosed() {
		}

		public void solve(int kase, InputReader in, Output pw) {
			int n = in.nextInt(), q = in.nextInt();
			EEyesClosed.SegmentTree st = new EEyesClosed.SegmentTree(in.nextDouble(n));
			while(q-->0) {
				if(in.nextInt()==1) {
					int a = in.nextInt()-1, b = in.nextInt()-1, c = in.nextInt()-1, d = in.nextInt()-1;
					double x = st.query(a, b), y = st.query(c, d);
					st.mul(a, b, (double) (b-a)/(b-a+1));
					st.mul(c, d, (double) (d-c)/(d-c+1));
					st.add(a, b, y/(d-c+1)/(b-a+1));
					st.add(c, d, x/(b-a+1)/(d-c+1));
				}else {
					pw.printf("%.4f\n", st.query(in.nextInt()-1, in.nextInt()-1));
				}
			}
		}

		static class SegmentTree {
			int n;
			int ql;
			int qr;
			double v;
			boolean qadd;
			double[] arr;
			double[] add;
			double[] mul;
			double[] sum;

			public SegmentTree(double[] arr) {
				n = arr.length;
				this.arr = arr;
				add = new double[4*n];
				mul = new double[4*n];
				sum = new double[4*n];
				build(1, 0, n-1);
			}

			public void maintain(int o, int l, int r) {
				if(l<r) {
					sum[o] = sum[o*2]+sum[o*2+1];
				}else {
					sum[o] = arr[l];
				}
				sum[o] = sum[o]*mul[o]+(r-l+1)*add[o];
			}

			public void pushdown(int o, int l, int r) {
				if(l<r) {
					for(int i = o*2; i<=o*2+1; i++) {
						mul[i] *= mul[o];
						add[i] *= mul[o];
						add[i] += add[o];
					}
					mul[o] = 1;
					add[o] = 0;
				}
			}

			public void build(int o, int l, int r) {
				mul[o] = 1;
				if(l==r) {
					sum[o] = arr[l];
				}else {
					int mid = (l+r)/2, lc = o*2, rc = o*2+1;
					build(lc, l, mid);
					build(rc, mid+1, r);
					maintain(o, l, r);
				}
			}

			public void update(int o, int l, int r) {
				if(l>=ql&&r<=qr) {
					if(qadd) {
						add[o] += v;
					}else {
						mul[o] *= v;
						add[o] *= v;
					}
				}else {
					pushdown(o, l, r);
					int mid = (l+r)/2, lc = o*2, rc = o*2+1;
					if(ql<=mid) {
						update(lc, l, mid);
					}else {
						maintain(lc, l, mid);
					}
					if(qr>mid) {
						update(rc, mid+1, r);
					}else {
						maintain(rc, mid+1, r);
					}
				}
				maintain(o, l, r);
			}

			public void query(int o, int l, int r, double cadd, double cmul) {
				if(l>=ql&&r<=qr) {
					v += sum[o]*cmul+(r-l+1)*cadd;
				}else {
					cadd += cmul*add[o];
					cmul *= mul[o];
					int mid = (l+r)/2;
					if(ql<=mid) {
						query(o*2, l, mid, cadd, cmul);
					}
					if(qr>mid) {
						query(o*2+1, mid+1, r, cadd, cmul);
					}
					maintain(o, l, r);
				}
			}

			public void add(int l, int r, double v) {
				ql = l;
				qr = r;
				this.v = v;
				qadd = true;
				update(1, 0, n-1);
			}

			public void mul(int l, int r, double v) {
				ql = l;
				qr = r;
				this.v = v;
				qadd = false;
				update(1, 0, n-1);
			}

			public double query(int l, int r) {
				ql = l;
				qr = r;
				v = 0;
				query(1, 0, n-1, 0, 1);
				return v;
			}

		}

	}

	static class FastReader implements InputReader {
		final private int BUFFER_SIZE = 1<<16;
		private final DataInputStream din;
		private final byte[] buffer;
		private int bufferPointer;
		private int bytesRead;

		public FastReader(InputStream is) {
			din = new DataInputStream(is);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public int nextInt() {
			int ret = 0;
			byte c = skipToDigit();
			boolean neg = (c=='-');
			if(neg) {
				c = read();
			}
			do {
				ret = ret*10+c-'0';
			} while((c = read())>='0'&&c<='9');
			if(neg) {
				return -ret;
			}
			return ret;
		}

		public double nextDouble() {
			double ret = 0, div = 1;
			byte c = skipToDigit();
			boolean neg = (c=='-');
			if(neg) {
				c = read();
			}
			do {
				ret = ret*10+c-'0';
			} while((c = read())>='0'&&c<='9');
			if(c=='.') {
				while((c = read())>='0'&&c<='9') {
					ret += (c-'0')/(div *= 10);
				}
			}
			if(neg) {
				return -ret;
			}
			return ret;
		}

		private boolean isDigit(byte b) {
			return b>='0'&&b<='9';
		}

		private byte skipToDigit() {
			byte ret;
			while(!isDigit(ret = read())&&ret!='-') ;
			return ret;
		}

		private void fillBuffer() {
			try {
				bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			}catch(IOException e) {
				e.printStackTrace();
				throw new InputMismatchException();
			}
			if(bytesRead==-1) {
				buffer[0] = -1;
			}
		}

		private byte read() {
			if(bytesRead==-1) {
				throw new InputMismatchException();
			}else if(bufferPointer==bytesRead) {
				fillBuffer();
			}
			return buffer[bufferPointer++];
		}

	}

	static class Output implements Closeable, Flushable {
		public StringBuilder sb;
		public OutputStream os;
		public int BUFFER_SIZE;
		public String lineSeparator;

		public Output(OutputStream os) {
			this(os, 1<<16);
		}

		public Output(OutputStream os, int bs) {
			BUFFER_SIZE = bs;
			sb = new StringBuilder(BUFFER_SIZE);
			this.os = new BufferedOutputStream(os, 1<<17);
			lineSeparator = System.lineSeparator();
		}

		public void print(String s) {
			sb.append(s);
			if(sb.length()>BUFFER_SIZE >> 1) {
				flushToBuffer();
			}
		}

		public void printf(String s, Object... o) {
			print(String.format(s, o));
		}

		private void flushToBuffer() {
			try {
				os.write(sb.toString().getBytes());
			}catch(IOException e) {
				e.printStackTrace();
			}
			sb = new StringBuilder(BUFFER_SIZE);
		}

		public void flush() {
			try {
				flushToBuffer();
				os.flush();
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

		public void close() {
			flush();
			try {
				os.close();
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

	}

	interface InputReader {
		int nextInt();

		double nextDouble();

		default double[] nextDouble(int n) {
			double[] ret = new double[n];
			for(int i = 0; i<n; i++) {
				ret[i] = nextDouble();
			}
			return ret;
		}

	}
}