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
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.flush();
		out.close();
	}
}

class Couple implements Comparable<Couple> {
	long first;
	int second;
	int third;

	Couple(long first, int second, int third) {
		this.first = first;
		this.second = second;
		this.third = third;
	}

	@Override
	public int compareTo(Couple arg0) {
		// TODO Auto-generated method stub
		return Long.compare(first, arg0.first);
	}

}

class TaskB {
	int INF = (int) 1e9 + 7;
	int MAX_N = (int) 1e5 + 5;
	long mod = (long) 1e8;
	ArrayList<Integer> edges[];
	ArrayList<Integer> rev_edges[];
	boolean visited[];
	ArrayList<Integer> topSort;
	int color[];
	ArrayList<Integer> list;

	public void solve(int testNumber, InputReader in, PrintWriter pw) {
		int n = in.nextInt();
		int a[] = new int[n];
		long sa = 0, sb = 0;
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
			sa += a[i];
		}
		int m = in.nextInt();
		int b[] = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = in.nextInt();
			sb += b[i];
		}
		int ways[][] = new int[0][];
		long min = Math.abs(sa - sb);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				long s1 = sa + (b[j] - a[i]);
				long s2 = sb + (a[i] - b[j]);
				long diff = Math.abs(s1 - s2);
//				System.out.println(sa + " " + sb + " " + diff);
				if (diff < min) {
					min = diff;
					ways = new int[][] { new int[] { i + 1, j + 1 } };
				}
			}
		}
		Couple a_sum[] = new Couple[n * (n - 1) / 2];
		Couple b_sum[] = new Couple[m * (m - 1) / 2];
		int p = 0;
		for (int i = 0; i < m; i++) {
			for (int j = i + 1; j < m; j++) {
				b_sum[p++] = new Couple((b[i] + b[j]), i + 1, j + 1);
			}
		}
		p = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				a_sum[p++] = new Couple((a[i] + a[j]), i + 1, j + 1);
			}
		}
		Arrays.sort(b_sum);
		Arrays.sort(a_sum);
		int at = 0;
		for (Couple x : a_sum) {
			while (at < b_sum.length) {
				long val = b_sum[at].first;
				long diff = sa - sb - 2 * x.first + 2 * val;
				long temp = Math.abs(diff);
				if (temp < min) {
					min = temp;
					ways = new int[][] { new int[] { x.second, b_sum[at].second },
							new int[] { x.third, b_sum[at].third } };
				}
				if (diff >= 0) {
					break;
				}
				at++;
			}
			if (at == b_sum.length) {
				break;
			}
		}
		pw.println(min);
		pw.println(ways.length);
		for (int[] x : ways) {
			for (int i = 0; i < 2; i++) {
				pw.print(x[i] + " ");
			}
			pw.println();
		}
	}

	void prepareList(int l, int r, int id, int n) {
		for (int i = l; i <= r; i++) {
			if (i % 2 != 0) {
				if (id == n) {
					list.add(1);
				} else {
					list.add(id);
				}
			} else {
				int temp = i / 2;
				list.add(id + temp);
			}
		}
	}

	long gcd(long a, long b) {
		if (b == 0) {
			return a;
		} else {
			return gcd(b, a % b);
		}
	}

	int[] shrink(int a[]) {
		int n = a.length;
		long b[] = new long[n];
		for (int i = 0; i < n; i++) {
			b[i] = ((long) (a[i] << 32)) | i;
		}
		Arrays.sort(b);
		int ret[] = new int[n];
		int p = 0;
		for (int i = 0; i < n; i++) {
			if (i > 0 && (b[i] ^ b[i - 1]) >> 32 != 0) {
				p++;
			}
			ret[(int) b[i]] = p;
		}
		return ret;
	}

	int sum(int ft[], int i) {
		int sum = 0;
		for (int j = i; j >= 1; j -= (j & -j)) {
			sum += ft[j];
//			System.out.println(sum);
		}
		return sum;
	}

	void add(int ft[], int i, int x) {
		for (int j = i; j < ft.length; j += (j & -j)) {
//			System.out.println(j);
			ft[j] += x;
		}
	}

	boolean isValid(int i, int j, char arr[][]) {

		if (i >= arr[0].length || j >= arr[0].length) {
			return false;
		}
		if (arr[i][j] == '*') {
			return false;
		}
		return true;
	}

	long pow(long m, long k) {
		long prod = 1;
		for (int i = 0; i < k; i++) {
			prod = (prod * m) % INF;
		}
		return prod % INF;
	}

//	int sum(int k) {
//		int sum=0;
//		for(int i=k;i>=1;i) {
//			sum+=ft[k];
//		}
//	}

	long fib(int N) {
		long fib[] = new long[N + 1];
		fib[0] = 1;
		fib[1] = 1;
		for (int i = 2; i <= N; i++) {
			fib[i] = (fib[i - 1] + fib[i - 2]) % mod;
		}
		return fib[N] % mod;
	}

	long sum(int i, int j, long arr[]) {
		long sum = 0;
		for (int k = i; k <= j; k++) {
			sum += arr[k];
		}
		return sum;
	}

	int __gcd(int a, int b) {
		if (b == 0)
			return a;
		return __gcd(b, a % b);

	}

	public int getInt(int num) {
		int ret = -1;
		switch (num) {
		case 0:
			ret = 6;
			break;
		case 1:
			ret = 2;
			break;
		case 2:
			ret = 5;
			break;
		case 3:
			ret = 5;
			break;
		case 4:
			ret = 4;
			break;
		case 5:
			ret = 5;
			break;
		case 6:
			ret = 6;
			break;
		case 7:
			ret = 3;
			break;
		case 8:
			ret = 7;
			break;
		case 9:
			ret = 6;
			break;
		}
		return ret;
	}

	public int isPow(long num) {
		int count = 0;
		while (num > 0) {
			num /= 2;
			count++;
		}
		return count;
	}
}

class InputReader {
	BufferedReader br;
	StringTokenizer st;

	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}