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.util.*;
import java.io.*;
public class D 
{
    public static void main(String[] args)
    {
        new D().solve();
    }

    FasterScanner in=new FasterScanner();
    PrintWriter out=new PrintWriter(System.out);

    public void solve()
    {
//    	int tt=in.nextInt();
//    	for(int ii=0;ii<tt;ii++)
    	{
    		int n=in.nextInt();
    		int[] a=new int[n];
    		long sa=0;
    		for(int i=0;i<n;i++)
    		{
    			a[i]=in.nextInt();
    			sa+=a[i];
    		}
    		int m=in.nextInt();
    		int[] b=new int[m];
    		long sb=0;
    		boolean sw=false;
    		for(int i=0;i<m;i++)
    		{
    			b[i]=in.nextInt();
    			sb+=b[i];
    		}
    		if(sa==sb)
    		{
    			out.println(0);
    			out.println(0);
    			out.close();
    			return;
    		}
    		else if(sb>sa)
    		{
    			sw=true;
    			int t=n;
    			n=m;
    			m=t;
    			int[] tt=a;
    			a=b;
    			b=tt;
    			long ttt=sa;
    			sa=sb;
    			sb=ttt;
    		}
    		
    		int ca=0,cb=0;
    		int ma=0,mb=0;
    		long min=sa-sb;
    		s[] ssa=new s[n];
    		s[] ssb=new s[m];
    		for(int i=0;i<n;i++)
    			ssa[i]=new s(i,a[i]);
    		for(int i=0;i<m;i++)
    			ssb[i]=new s(i,b[i]);
    		
    		Arrays.sort(ssa);
    		Arrays.sort(ssb);
    		while(ca<a.length && cb<b.length)
    		{
    			long vv=2L*((long)ssa[ca].val-ssb[cb].val);
    			if(min>Math.abs(sa-sb-vv))
    			{
    				min=Math.abs(sa-sb-vv);
    				ma=ssa[ca].idx;
    				mb=ssb[cb].idx;
    			}
    			if(vv>sa-sb)
    			{
    				cb++;
    			}
    			else
    			{
    				ca++;
    			}
    		}
    		
//    		ca=0;
//    		cb=0;
//    		while(ca<a.length && cb<b.length)
//    		{
//    			long vv=2*(ssa[ca].val-ssb[cb].val);
//    			if(min>Math.abs(sa-sb-vv))
//    			{
//    				min=Math.abs(sa-sb-vv);
//    				ma=ssa[ca].idx;
//    				mb=ssb[cb].idx;
//    			}
//    			if(vv<sa-sb)
//    			{
//    				ca++;
//    			}
//    			else
//    			{
//    				cb++;
//    			}
//    		}

        	d[] a1=new d[(n*(n-1))/2];
        	d[] b1=new d[(m*(m-1))/2];
        	int c=0;
        	for(int i=0;i<n;i++)
        	{
        		for(int j=i+1;j<n;j++)
        		{
        			a1[c++]=new d(i,j,a[i]+a[j]);
        		}
        	}
        	c=0;
        	for(int i=0;i<m;i++)
        	{
        		for(int j=i+1;j<m;j++)
        		{
        			b1[c++]=new d(i,j,b[i]+b[j]);
        		}
        	}
        	
        	Arrays.sort(a1);
        	Arrays.sort(b1);
        	ca=0;
        	cb=0;
        	
        	int mx1=0,my1=0,mx2=0,my2=0;
        	boolean bb=false;
        	while(ca<a1.length && cb<b1.length)
    		{
    			long vv=2L*((long)a1[ca].val-b1[cb].val);
    			if(min>Math.abs(sa-sb-vv))
    			{
    				min=Math.abs(sa-sb-vv);
    				mx1=a1[ca].id1;
    				mx2=a1[ca].id2;
    				my1=b1[cb].id1;
    				my2=b1[cb].id2;
    				
    				bb=true;
    			}
    			if(vv>sa-sb)
    			{
    				cb++;
    			}
    			else
    			{
    				ca++;
    			}
    		}
    		
    		
//    		ca=0;
//    		cb=0;
//    		while(ca<a1.length && cb<b1.length)
//    		{
//    			long vv=2*(a1[ca].val-b1[cb].val);
//    			if(min>Math.abs(sa-sb-vv))
//    			{
//    				min=Math.abs(sa-sb-vv);
//    				mx1=a1[ca].id1;
//    				mx2=a1[ca].id2;
//    				my1=b1[cb].id1;
//    				my2=b1[cb].id2;
//    				
//    				bb=true;
//    			}
//    			if(vv<sa-sb)
//    			{
//    				ca++;
//    			}
//    			else
//    			{
//    				cb++;
//    			}
//    		}
    		
    		if(min==sa-sb)
    		{
    			System.out.println(sa-sb);
    			System.out.println(0);
    		}
    		else if(bb)
    		{
    			System.out.println(min);
    			System.out.println(2);
    			if(!sw)
    			{
    				System.out.println((mx1+1)+" "+(my1+1));
    				System.out.println((mx2+1)+" "+(my2+1));
    			}
    			else
    			{
    				System.out.println((my1+1)+" "+(mx1+1));
    				System.out.println((my2+1)+" "+(mx2+1));
    			}
    		}
    		else
    		{
    			
    		
    			System.out.println(min);
    			System.out.println(1);
    			if(!sw)
    			{
    				System.out.println((ma+1)+" "+(mb+1));
    			}
    			else
    			{
    				System.out.println((mb+1)+" "+(ma+1));
    			}
    		}
        			
    	}
    	
    	
    	
        out.close();
    }
    
    
    
    class d implements Comparable<d>
    {
    	int val;
    	int id1;
    	int id2;
    	
    	public d(int i1,int i2,int s)
    	{
    		this.val=s;
    		this.id1=i1;
    		this.id2=i2;
    	}

		public int compareTo(d o) {
			// TODO Auto-generated method stub
			return Long.compare(val, o.val);
			
		}
    	
    }
    class s implements Comparable<s>
    {
        int idx;
        int val;
        public s(int i,int f)
        {
            this.idx=i;
            this.val=f;
        }

        @Override
        public int compareTo(s o) {
            // TODO Auto-generated method stub
        	return Long.compare(this.val, o.val);
        }
    }

    public static class FasterScanner {
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = System.in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
        private boolean isEndOfLine(int c) {
            return c=='\n' || c=='\r' || c==-1;
        }
        public String nextString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
        private boolean isSpaceChar(int c) {
            return c=='\n' || c=='\r' || c==-1 || c==' ' || c=='\t';
        }
        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public double nextDouble()
        {
            return Double.parseDouble(nextString());
        }
        public int[] nextIntArray(int n)
        {
            int[] arr=new int[n];
            for(int i=0;i<n;i++)
            {
                arr[i]=nextInt();
            }
            return arr;
        }
        public long[] nextLongArray(int n)
        {
            long[] arr=new long[n];
            for(int i=0;i<n;i++)
            {
                arr[i]=nextLong();
            }
            return arr;
        }
        public int[] nextIntArray10(int n)
        {
            int[] arr=new int[n+1];
            for(int i=1;i<=n;i++)
            {
                arr[i]=nextInt();
            }
            return arr;
        }
        public long[] nextLongArray10(int n)
        {
            long[] arr=new long[n+1];
            for(int i=1;i<=n;i++)
            {
                arr[i]=nextLong();
            }
            return arr;
        }
        public int[] nextIntArray11(int n)
        {
            int[] arr=new int[n+2];
            for(int i=1;i<=n;i++)
            {
                arr[i]=nextInt();
            }
            return arr;
        }
        public long[] nextLongArray11(int n)
        {
            long[] arr=new long[n+2];
            for(int i=1;i<=n;i++)
            {
                arr[i]=nextLong();
            }
            return arr;
        }
    }

}