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.IOException;
import java.io.InputStreamReader;
import java.security.Key;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;

public class ArraySwapDiff2 {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line = in.readLine();
		StringTokenizer st = new StringTokenizer(line);

		int n = Integer.parseInt(st.nextToken());
		long[] a = new long[n];
		line = in.readLine();
		st = new StringTokenizer(line);
		long sumA = 0;
		for (int i = 0; i < n; i++) {
			int x = Integer.parseInt(st.nextToken());
			a[i] = 2L*x;
			sumA += x;
		}

		line = in.readLine();
		st = new StringTokenizer(line);
		int m = Integer.parseInt(st.nextToken());
		long[] b = new long[m];
		line = in.readLine();
		in.close();
		st = new StringTokenizer(line);
		// TreeMap<Long, Integer> bVals = new TreeMap<>();

		ArrayList<Node> bList = new ArrayList<>();
		
		long sumB = 0;
		for (int i = 0; i < m; i++) {
			b[i] = Integer.parseInt(st.nextToken());
			sumB += b[i];
			b[i] *= 2;
			bList.add(new Node(b[i], i+1));
		}
		
		long diff = sumB - sumA;
		Collections.sort(bList);
		//HeapSort.sort(bVals);

		//Arrays.sort(bVals, comp);
	    //System.out.println("Diff is " + diff);
		long min = Math.abs(diff);
		int[][] swaps = new int[2][2];

		Node key = new Node(0,0);
		for (int i = 0; i < n; i++) {
			key.value = a[i] + diff;
			int idx = Collections.binarySearch(bList, key);

			if (idx < 0) {
				idx = -idx - 1;
			}
			
			//System.out.format("Found idx = %d with key = %d\n", idx, key.value);
			
			if (idx > 0) {
				Node bNode = bList.get(idx - 1);
				long bKey = bNode.value;

				long newDiff = Math.abs(key.value - bKey);
				if (newDiff < min) {
					min = newDiff;
					swaps[0][0] = i + 1;
					swaps[0][1] = bNode.a;
				}
			}
			if (idx < m) {
				Node bNode = bList.get(idx);
				long bKey = bNode.value;
				long newDiff = Math.abs(key.value - bKey);
				if (newDiff < min) {
					min = newDiff;
					swaps[0][0] = i + 1;
					swaps[0][1] = bNode.a;
				}
			}
		}

		// System.out.format("Min is %d after round 1", min);
		// do the pairwise sums



		bList.clear();
		for (int i = 0; i < m; i++) {
			for (int j = i + 1; j < m; j++) {
				long bsum = b[i] + b[j];
				bList.add(new Node(bsum, i+1, j+1));
			}
		}

		//HeapSort.sort(bVals);
		Collections.sort(bList);

		final int m2 = bList.size();
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				key.value = a[i] + a[j] + diff;
				int idx = Collections.binarySearch(bList, key);

				if (idx < 0) {
					idx = -idx - 1;
				}

				if (idx > 0) {
					Node bNode = bList.get(idx - 1);

					long newDiff = Math.abs(key.value - bNode.value);
					if (newDiff < min) {
						min = newDiff;
						swaps[0][0] = i + 1;
						swaps[0][1] = bNode.a;
						swaps[1][0] = j + 1;
						swaps[1][1] = bNode.b;
					}
				}
				if (idx < m2) {
					Node bNode = bList.get(idx);
					long newDiff = Math.abs( key.value - bNode.value);
					if (newDiff < min) {
						min = newDiff;
						swaps[0][0] = i + 1;
						swaps[0][1] = bNode.a;
						swaps[1][0] = j + 1;
						swaps[1][1] = bNode.b;
					}
				}
			}
		}

		//HeapSort.sort(aVals);
		//Arrays.sort(aVals, comp);

		// walk both arrays
//		for (int i = 0, j = 0; i < apSize && j < bpSize;) {
//			long av = (long) aVals[i][0];
//			long bv = (long) bVals[j][0];
//			long newDiff = Math.abs(av - bv);
//			if (newDiff < min) {
//				min = newDiff;
//				swaps[0][0] = (int) aVals[i][1];
//				swaps[0][1] = (int) bVals[j][1];
//				swaps[1][0] = (int) aVals[i][2];
//				swaps[1][1] = (int) bVals[j][2];
//			}
//			if (av > bv) {
//				i++;
//			} else {
//				j++;
//			}
//		}

		// for (int i = 0; i < n; i++) {
		// for (int j = i + 1; j < n && min > 0; j++) {
		// long asum = 2 * (a[i] + a[j]);
		// idx = Arrays.binarySearch(bVals, new Object[] { diff + asum }, comp);
		//
		// if (idx < 0) {
		// idx = -idx - 1;
		// }
		// if (idx > 0) {
		// long bKey = (long) bVals[idx - 1][0];
		// long newDiff = Math.abs(diff + asum - bKey);
		// if (newDiff < min) {
		// min = newDiff;
		// int[] bp = (int[]) bVals[idx - 1][1];
		// swaps[0][0] = i + 1;
		// swaps[0][1] = bp[0];
		// swaps[1][0] = j + 1;
		// swaps[1][1] = bp[1];
		// //System.out.format("idx - 1, i = %d, j = %d, min = %d\n", i, j,
		// min);
		// }
		// }
		// if (idx < bpSize) {
		// long bKey = (long) bVals[idx][0];
		// long newDiff = Math.abs(diff + asum - bKey);
		// if (newDiff < min) {
		// min = newDiff;
		// int[] bp = (int[]) bVals[idx][1];
		// swaps[0][0] = i + 1;
		// swaps[0][1] = bp[0];
		// swaps[1][0] = j + 1;
		// swaps[1][1] = bp[1];
		// //System.out.format("idx, i = %d, j = %d, min = %d\n", i, j, min);
		// }
		// }
		// }
		// }
		System.out.println(min);
		if (swaps[1][0] != 0) {
			System.out.println(2);
			System.out.format("%d %d\n", swaps[0][0], swaps[0][1]);
			System.out.format("%d %d\n", swaps[1][0], swaps[1][1]);
		} else if (swaps[0][0] != 0) {
			System.out.println(1);
			System.out.format("%d %d\n", swaps[0][0], swaps[0][1]);
		} else {
			System.out.println(0);
		}
	}

	private static class ArrayComp implements Comparator<long[]> {

		@Override
		public int compare(long[] o1, long[] o2) {
			long v1 = o1[0];
			long v2 = o2[0];
			if (v1 > v2) {
				return -1;
			} else if (v1 < v2) {
				return 1;
			}
			return 0;
		}

	}
	
	private static class Node implements Comparable<Node> {
		private long value;
		private final int a, b;
		Node(long v, int a, int b) {
			value = v;
			this.a = a;
			this.b = b;
		}
		
		Node (long v, int a) {
			this(v, a, 0);
		}

		@Override
		public int compareTo(Node o) {
			if ( value < o.value ) {
				return -1;
			} else if ( value > o.value ) {
				return 1;
			}
			return 0;
		}
	}
}

