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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

// Educational Codeforces Round 6
// Professor GukiZ and Two Arrays
public class Problem_620_D {

  static class Pair implements Comparable<Pair> {
    long first;

    int second;

    Pair(long f, int s)
    {
      first = f;
      second = s;
    }

    public int compareTo(Pair o)
    {
      int r = Long.compare(first,  o.first);

      if(r == 0)
        r = Integer.compare(second, o.second);

      return r;
    }

    @Override
    public String toString()
    {
      return "Pair(" + first + "," + second + ")";
    }
  }

  public static void main(String[] args)
  {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    PrintWriter out = new PrintWriter(outputStream);
    Problem_620_D solver = new Problem_620_D();
    solver.solve(1, new InputStreamReader(inputStream), out);
    out.close();
  }

  public void solve(int test, Reader input, PrintWriter out)
  {
    MyScanner in = new MyScanner(input);

    int n = in.nextInt();

    int[] a = in.nextIntArray(n);

    int m = in.nextInt();

    int[] b = in.nextIntArray(m);

    long sa = 0;
    for(int i : a)
      sa += i;
    long sb = 0;
    for(int i : b)
      sb += i;

    long ansv = Long.MAX_VALUE;
    int[] ansp = new int[2];
    int ansl = 0;

    long curv = Math.abs(sa - sb);
    if (ansv > curv) {
      ansv = curv;
    }

    for(int i = 0; i < n; i++)
      for(int j = 0; j < m; j++) {
        sa += b[j] - a[i];
        sb += a[i] - b[j];
        curv = Math.abs(sa - sb);
        if (ansv > curv) {
          ansv = curv;
          ansl = 1;
          ansp[0] = i * 10_000 + j;
        }
        sa -= b[j] - a[i];
        sb -= a[i] - b[j];
      }

    ArrayList<Pair> z = new ArrayList<>();
    for(int j = 0; j < n; j++)
      for(int i = 0; i < j; i++) {
        long v= 2L * (a[i] + a[j]);
        z.add(new Pair(v, i * 10_000 + j));
      }

    Collections.sort(z);

    if(z.size() > 0)
      for(int j = 0; j < m; j++)
        for(int i = 0; i < j; i++) {
          long val = sa - sb + 2L * (b[i] + b[j]);
          int it = binarySearch(z,  val);
          if(it < 0) it = -it-1;
          if(it > 0) it--;
          for(int k = 0; k < 2; k++) {
            if (it == z.size()) break;
            Pair pa = z.get(it);
            curv = Math.abs(val - pa.first);
            int p = pa.second;
            int first = p / 10_000;
            int second = p % 10_000;
            assert(Math.abs(sa - 2L * (a[first] + a[second]) - (sb - 2L * (b[i] + b[j]))) == curv);
            if (ansv > curv) {
              ansv = curv;
              ansl = 2;
              ansp[0] = first * 10_000 + i;
              ansp[1] = second * 10_000 + j;
            }
            it++;
          }
        }


    assert(ansv != Long.MAX_VALUE);
    out.println(ansv);
    out.println(ansl);
    for(int i = 0; i < ansl; i++)
      out.println((ansp[i] / 10_000 + 1) + " " + ((ansp[i] % 10_000) + 1));

  }

  int binarySearch(ArrayList<Pair> list, long diff)
  {
    int top = list.size();

    int l = 0;
    int r = top - 1;
    int m = -1;
    while(l <= r) {
      m = (l + r) / 2;
      Pair p = list.get(m);
      if(p.first > diff)
        r = m - 1;
      else if(p.first < diff)
        l = m + 1;
      else
        return m;
    }
    return -m - (diff < list.get(m).first ? 1 : 2);
  }

  //-----------MyScanner class for faster input----------
  public static class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    public MyScanner(Reader reader) {
      br = new BufferedReader(reader);
    }

    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());
    }

    int[] nextIntArray(int n) {
      int[] r = new int[n];
      for(int i = 0; i < n; i++)
        r[i] = nextInt();
      return r;
    }

    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;
    }

  }
  //--------------------------------------------------------

}