The only difference between easy and hard versions is a number of elements in the array.

You are given an array a consisting of n integers. The value of the i-th element of the array is a_i.

You are also given a set of m segments. The j-th segment is [l_j; r_j], where 1 ≤ l_j ≤ r_j ≤ n.

You can choose some subset of the given set of segments and decrease values on each of the chosen segments by one (independently). For example, if the initial array a = [0, 0, 0, 0, 0] and the given segments are [1; 3] and [2; 4] then you can choose both of them and the array will become b = [-1, -2, -2, -1, 0].

You have to choose some subset of the given segments (each segment can be chosen at most once) in such a way that if you apply this subset of segments to the array a and obtain the array b then the value max_{i=1}^{n}b_i - min_{i=1}^{n}b_i will be maximum possible.

Note that you can choose the empty set.

If there are multiple answers, you can print any.

If you are Python programmer, consider using PyPy instead of Python when you submit your code.

Input

The first line of the input contains two integers n and m (1 ≤ n ≤ 300, 0 ≤ m ≤ 300) — the length of the array a and the number of segments, respectively.

The second line of the input contains n integers a_1, a_2, ..., a_n (-10^6 ≤ a_i ≤ 10^6), where a_i is the value of the i-th element of the array a.

The next m lines are contain two integers each. The j-th of them contains two integers l_j and r_j (1 ≤ l_j ≤ r_j ≤ n), where l_j and r_j are the ends of the j-th segment.

Output

In the first line of the output print one integer d — the maximum possible value max_{i=1}^{n}b_i - min_{i=1}^{n}b_i if b is the array obtained by applying some subset of the given segments to the array a.

In the second line of the output print one integer q (0 ≤ q ≤ m) — the number of segments you apply.

In the third line print q distinct integers c_1, c_2, ..., c_q in any order (1 ≤ c_k ≤ m) — indices of segments you apply to the array a in such a way that the value max_{i=1}^{n}b_i - min_{i=1}^{n}b_i of the obtained array b is maximum possible.

If there are multiple answers, you can print any.

Examples

Input


5 4
2 -2 3 1 2
1 3
4 5
2 5
1 3


Output


6
2
1 4 


Input


5 4
2 -2 3 1 4
3 5
3 4
2 4
2 5


Output


7
2
3 2 


Input


1 0
1000000


Output


0
0

Note

In the first example the obtained array b will be [0, -4, 1, 1, 2] so the answer is 6.

In the second example the obtained array b will be [2, -3, 1, -1, 4] so the answer is 7.

In the third example you cannot do anything so the answer is 0.
import java.util.*;
import java.io.*;
import java.sql.Array;
 
public class E {
 
	static final boolean stdin = true;
	static final String filename = "";
	static FastScanner br;
	static PrintWriter pw;
 
	public static void main(String[] args) throws IOException {
 
		if (stdin) {
			br = new FastScanner();
			pw = new PrintWriter(new OutputStreamWriter(System.out));
		} else {
			br = new FastScanner(filename + ".in");
			pw = new PrintWriter(new FileWriter(filename + ".out"));
		}
 
		Solver solver = new Solver();
		solver.solve(br, pw);
		pw.close();
	}
 
	static class Solver {
		static long mod = (long) (1e9);
 
		public void solve(FastScanner br, PrintWriter pw) throws IOException {
			int n = br.ni();
			int m = br.ni();
			if(n==1){
				pw.println(0);
				pw.println(0);
				pw.close();
				System.exit(0);
			}
			long[] temp = br.nla(n);
			long[] fen = new long[n + 1];
			for (int i = 0; i < n; i++) {
				fen[i + 1] = temp[i];
			}
			int[][] ranges = new int[m][2];
			for (int i = 0; i < m; i++) {
				ranges[i][0] = br.ni();
				ranges[i][1] = br.ni();
			}
			long[] diffs = new long[n + 1];
			for (int i = 1; i <= n; i++) {
				FenwickRUPQ copy = new FenwickRUPQ(fen);
				for (int j = 0; j < m; j++) {
					if (!(ranges[j][0] <= i && i <= ranges[j][1])) {
						copy.updateRange(ranges[j][0], ranges[j][1], -1);
					}
				}
				long min = copy.get(1);
				int mindex = 1;
				for (int j = 2; j <= n; j++) {
					long g = copy.get(j);
					if (g < min) {
						min = g;
						mindex = j;
					}
				
				}
				diffs[i] = fen[i] - copy.get(mindex);
			}
			long max = Integer.MIN_VALUE;
			for (long i : diffs) {
				max = Math.max(max, i);
			}
			for (int i = 1; i <= n; i++) {
				if (diffs[i] == max) {
					pw.println(max);
					ArrayList<Integer> choice = new ArrayList<Integer>();
					for (int j = 0; j < m; j++) {
						if (!(ranges[j][0] <= i && i <= ranges[j][1])) {
							choice.add(j+1);
						}
					}
					 pw.println(choice.size());
					for (int j : choice) {
						 pw.print(j + " ");
					}
					break;
				}
			}
		}
 
		static long gcd(long a, long b) {
			if (a > b)
				return gcd(b, a);
			if (a == 0)
				return b;
			return gcd(b % a, a);
		}
 
		static long lcm(long a, long b) {
			return a * (b / gcd(a, b));
		}
 
		static long pow(long a, long b) {
			if (b == 0)
				return 1L;
			long val = pow(a, b / 2);
			if (b % 2 == 0)
				return val * val % mod;
			else
				return val * val % mod * a % mod;
		}
 
	}
 
	static class FenwickRUPQ {
		// The size of the array holding the Fenwick tree values
		final int N;
		// This array contains the original Fenwick tree range
		// values from when it was first created.
		private long[] originalTree;
		// The current tree will contain the updated range values
		private long[] currentTree;
 
		// Construct a Fenwick tree with an initial set of values.
		// The 'values' array MUST BE ONE BASED meaning values[0]
		// does not get used, O(n) construction.
		public FenwickRUPQ(long[] values) {
			if (values == null)
				throw new IllegalArgumentException("Values array cannot be null!");
			N = values.length;
			values[0] = 0L;
			// Make a clone of the values array since we manipulate
			// the array in place destroying all its original content.
			long[] fenwickTree = values.clone();
			for (int i = 1; i < N; i++) {
				int parent = i + lsb(i);
				if (parent < N)
					fenwickTree[parent] += fenwickTree[i];
			}
			originalTree = fenwickTree;
			currentTree = fenwickTree.clone();
		}
 
		// Update the interval [left, right] with the value 'val', O(log(n))
		public void updateRange(int left, int right, long val) {
			add(left, +val);
			add(right + 1, -val);
		}
 
		// Add 'v' to index 'i' and all the ranges responsible for 'i',
		// O(log(n))
		private void add(int i, long v) {
			while (i < N) {
				currentTree[i] += v;
				i += lsb(i);
			}
		}
 
		// Get the value at a specific index. The logic behind this method is
		// the same as finding the prefix sum in a Fenwick tree except that you
		// need to take the difference between the current tree and the original
		// to get the point value.
		public long get(int i) {
			return prefixSum(i, currentTree) - prefixSum(i - 1, originalTree);
		}
 
		// Computes the prefix sum from [1, i], O(log(n))
		private long prefixSum(int i, long[] tree) {
			long sum = 0L;
			while (i != 0) {
				sum += tree[i];
				i &= ~lsb(i); // Equivalently, i -= lsb(i);
			}
			return sum;
		}
 
		// Returns the value of the least significant bit (LSB)
		// lsb(108) = lsb(0b1101100) = 0b100 = 4
		// lsb(104) = lsb(0b1101000) = 0b1000 = 8
		// lsb(96) = lsb(0b1100000) = 0b100000 = 32
		// lsb(64) = lsb(0b1000000) = 0b1000000 = 64
		private static int lsb(int i) {
			// Isolates the lowest one bit value
			return i & -i;
			// An alternative method is to use the Java's built in method
			// return Integer.lowestOneBit(i);
		}
	}
 
	static class Point implements Comparable<Point> {
		int a;
		int b;
 
		Point(int a, int b) {
			this.a = a;
			this.b = b;
		}
 
		@Override
		public int compareTo(Point o) {
			return this.a - o.a;
		}
 
		public boolean equals(Object obj) {
			if (obj instanceof Point) {
				Point other = (Point) obj;
				return a == other.a && b == other.b;
			}
			return false;
		}
 
		public int hashCode() {
			return 65536 * a + b + 4733 * 0;
		}
 
	}
 
	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
 
		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
 
		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		ArrayList<Integer>[] ng(int n, int e) {
			ArrayList<Integer>[] adj = new ArrayList[n];
			for (int i = 0; i < n; i++) {
				adj[i] = new ArrayList<Integer>();
			}
			for (int i = 0; i < e; i++) {
				int a = ni() - 1;
				int b = ni() - 1;
				adj[a].add(b);
				adj[b].add(a);
			}
			return adj;
		}
 
		Integer[] nIa(int n) {
			Integer[] arr = new Integer[n];
			for (int i = 0; i < n; i++) {
				arr[i] = ni();
			}
			return arr;
		}
 
		int[] nia(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = ni();
			}
			return arr;
		}
 
		Long[] nLa(int n) {
			Long[] arr = new Long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nl();
			}
			return arr;
		}
 
		long[] nla(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nl();
			}
			return arr;
		}
 
		String[] nsa(int n) {
			String[] arr = new String[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nt();
			}
			return arr;
		}
 
		String nt() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int ni() {
			return Integer.parseInt(nt());
		}
 
		long nl() {
			return Long.parseLong(nt());
		}
 
		double nd() {
			return Double.parseDouble(nt());
		}
 
	}
}