Problem: Professor GukiZ has two arrays of integers, a and b. Professor wants to make the sum of the elements in the array a sa as close as possible to the sum of the elements in the array b sb. So he wants to minimize the value v = |sa - sb|.

In one operation professor can swap some element from the array a and some element from the array b. For example if the array a is [5, 1, 3, 2, 4] and the array b is [3, 3, 2] professor can swap the element 5 from the array a and the element 2 from the array b and get the new array a [2, 1, 3, 2, 4] and the new array b [3, 3, 5].

Professor doesn't want to make more than two swaps. Find the minimal value v and some sequence of no more than two swaps that will lead to the such value v. Professor makes swaps one by one, each new swap he makes with the new arrays a and b.

Input

The first line contains integer n (1 ≤ n ≤ 2000) — the number of elements in the array a.

The second line contains n integers ai ( - 109 ≤ ai ≤ 109) — the elements of the array a.

The third line contains integer m (1 ≤ m ≤ 2000) — the number of elements in the array b.

The fourth line contains m integers bj ( - 109 ≤ bj ≤ 109) — the elements of the array b.

Output

In the first line print the minimal value v = |sa - sb| that can be got with no more than two swaps.

The second line should contain the number of swaps k (0 ≤ k ≤ 2).

Each of the next k lines should contain two integers xp, yp (1 ≤ xp ≤ n, 1 ≤ yp ≤ m) — the index of the element in the array a and the index of the element in the array b in the p-th swap.

If there are several optimal solutions print any of them. Print the swaps in order the professor did them.

Examples

Input

5
5 4 3 2 1
4
1 1 1 1


Output

1
2
1 1
4 2


Input

5
1 2 3 4 5
1
15


Output

0
0


Input

5
1 2 3 4 5
4
1 2 3 4


Output

1
1
3 1

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;
public class d {
public static void main(String[] args) throws IOException {
	input.init(System.in);
	PrintWriter out = new PrintWriter(System.out);
	int n = input.nextInt();
	long[] as = new long[n];
	long sa = 0, sb = 0;
	for(int i = 0; i<n; i++) sa+=as[i] = input.nextInt();
	int m = input.nextInt();
	long[] bs = new long[m];
	for(int i = 0; i<m; i++) sb+=bs[i] = input.nextInt();
	long opt = (sa-sb);
	ArrayList<Long> ap = new ArrayList<Long>();
	for(int i = 0; i<n; i++)
		for(int j = i+1; j<n; j++)
		{
			ap.add((2L*(as[i] + as[j])));
		}
	Collections.sort(ap);
	long ba = -1;
	int bestai = -1, bestaj = -1, bestbi = -1, bestbj = -1;
	long bestDiff = Math.abs((long)opt);
	for(int i = 0; i<m; i++)
		for(int j = i+1; j<m; j++)
		{
			long p = 2L*(bs[i] + bs[j]) + opt;
			Long[] a = floorCeiling(ap, p);
			
			Long lower = a[0];
			if(lower != null)
			{
				long diff = Math.abs(p - lower);
				if(diff < bestDiff)
				{
					ba = lower;
					//bestai = lower.i;
					//bestaj = lower.j;
					bestbi = i;
					bestbj = j;
					bestDiff = diff;
				}
			}
			Long upper = a[1];
			if(upper != null)
			{
				long diff = Math.abs(p - upper);
				if(diff < bestDiff)
				{
					ba = upper;
					bestbi = i;
					bestbj = j;
					bestDiff = diff;
				}
			}
		}
	int besta = -1, bestb = -1;
	for(int i = 0; i<n; i++)
		for(int j = 0; j<m; j++)
		{
			long diff = Math.abs(2*(bs[j] - as[i]) + opt);
			if(diff < bestDiff)
			{
				bestDiff = diff;
				besta = i;
				bestb = j;
				ba = bestai = bestaj = bestbi = bestbj = -1;
			}
		}
	if(ba != -1)
	{
		for(int i = 0;i<n;i++)
			for(int j=i+1;j<n;j++)
			{
				if(2*as[i]+2L*as[j] == ba)
				{
					bestai = i;
					bestaj  = j;
				}
			}
		long diff = (long)bs[bestbi] + bs[bestbj] - as[bestai] - as[bestaj];
		sa += diff;
		sb -= diff;
		out.println(Math.abs(sa-sb));
		out.println(2);
		out.println((1+bestai)+" "+(1+bestbi)+"\n"+(1+bestaj)+" "+(1+bestbj));
	}
	else if(besta != -1)
	{
		long diff = bs[bestb] - as[besta];
		sa += diff;
		sb -= diff;
		out.println(Math.abs(sa-sb));
		out.println(1);
		out.println((1+besta)+" "+(1+bestb));
	}
	else
	{
		out.println(Math.abs(sa-sb)+"\n"+0);
	}
	
	out.close();
}
static Long[] floorCeiling(ArrayList<Long> list, long x)
{
	int lo = -1, hi = list.size();
	while(lo < hi - 1)
	{
		int mid = (lo+hi)/2;
		if(list.get(mid) >= x) hi = mid;
		else lo = mid;
	}
	Long[] res = new Long[2];
	if(lo > -1) res[0] = list.get(lo);
	if(hi < list.size()) res[1] = list.get(hi);
	return res;
}
static class Pair implements Comparable<Pair>
{
	long sum;
	int i, j;
	public Pair(long ss, int ii, int jj)
	{
		sum = ss; i = ii; j = jj;
	}
	@Override
	public int compareTo(Pair o) {
		// TODO Auto-generated method stub
		return Long.signum(sum - o.sum);
	}
}
public static class input {
	static BufferedReader reader;
	static StringTokenizer tokenizer;

	static void init(InputStream input) {
		reader = new BufferedReader(new InputStreamReader(input));
		tokenizer = new StringTokenizer("");
	}

	static String next() throws IOException {
		while (!tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(reader.readLine());
		return tokenizer.nextToken();
	}

	static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	static long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}
}