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 I {
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);
		long sum1=0,sum2=0;
		int n=sc.nextInt();
		int [] a=new int [n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			sum1+=a[i];
		}
		int m=sc.nextInt();
		int [] b=new int [m];
		for(int i=0;i<m;i++){
			b[i]=sc.nextInt();
			sum2+=b[i];
		}
		
		long min=Math.abs(sum1-sum2);
		int cnt=0;
		ArrayList<String> swap=new ArrayList<String>();
		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++){
				long newD=Math.abs(sum1-a[i]+b[j]-(sum2-b[j]+a[i]));
				if(newD<min){
					min=newD;
					cnt=1;
					swap.clear();
					swap.add((i+1)+" "+(j+1));
				}
			}
		ArrayList<pair> A=new ArrayList<I.pair>();
		ArrayList<pair> B=new ArrayList<I.pair>();
		for(int i=0;i<n;i++)
			for(int j=i+1;j<n;j++)
				A.add(new pair(i, j, a[i]+a[j]));
		for(int i=0;i<m;i++)
			for(int j=i+1;j<m;j++)
				B.add(new pair(i, j, b[i]+b[j]));
		Collections.sort(B);
		
		
		for(int i=0;i<A.size();i++){
			int start=0,end=B.size()-1;
			while(start<=end){
				int mid=((start+end)>>1);
				long newA=sum1-A.get(i).v+B.get(mid).v;
				long newB=sum2-B.get(mid).v+A.get(i).v;
				long newD=Math.abs(newA-newB);
				if(newD<min){
					min=newD;
					cnt=2;
					swap.clear();
					swap.add(A.get(i).i+" "+B.get(mid).j);
					swap.add(A.get(i).j+" "+B.get(mid).i);
				}
				if(newA<newB)
					start=mid+1;
				else
					end=mid-1;
			}
		}
		
		
		pw.println(min);
		pw.println(cnt);
		for(String s : swap)
			pw.println(s);
		pw.flush();
		pw.close();
	}
	
	static class pair implements Comparable<pair>{
		int i,j,v;
		pair(int i,int j,int v){
			this.i=i+1;
			this.j=j+1;
			this.v=v;
		}
		public int compareTo(pair o) {
			return Integer.compare(v, o.v);
		}
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			try {
				br = new BufferedReader(new FileReader(new File("interesting.in")));
			} catch (FileNotFoundException e) {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
			}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
}