#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

bool cmp(pair<int, int> a, pair<int, int> b)
{
    return a > b;
}

int main()
{
    freopen("wall.in", "r", stdin);
    freopen("wall.out", "w", stdout);
    int n, m;
    cin >> n;
    vector<pair<int, int> > a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i].first, a[i].second = i;
    cin >> m;
    vector<pair<int, int> > b(m);
    for (int i = 0; i < m; i++)
        cin >> b[i].first, b[i].second = i;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), cmp);
    vector<pair<int, int> > ans;
    int minn = (int)2e9 + 7;
    for (int i = 0, j = 0; i < n; i++)
    {
        if (j < m)
        {
            ans.push_back(make_pair(i, j));
            a[i].first += b[j].first;
            j++;
        }
        minn = min(minn, a[i].first);
    }
    cout << minn << " " << ans.size() << endl;
    for (int i = 0; i < (int)ans.size(); i++)
        cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << endl;
    return 0;
}