#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
pair<long long, long long> a[maxn];
long long b[maxn];
long long c1[maxn], c2[maxn];
long long n, k, w, sum;
pair<long long, long long> j[maxn];
set<pair<long long, long long> > s;
bool amx1(long long i, long long j) { return a[i].first < a[j].first; }
bool amx2(long long i, long long j) { return b[i] < b[j]; }
int main() {
  cin >> n;
  for (long long y = 1; y <= n; y++)
    cin >> a[y].first >> a[y].second, c1[y] = y;
  cin >> k;
  for (long long y = 1; y <= k; y++) cin >> b[y], c2[y] = y;
  sort(c1 + 1, c1 + n + 1, amx1);
  sort(c2 + 1, c2 + k + 1, amx2);
  long long i = 1;
  for (long long y = 1; y <= k; y++) {
    long long x = c2[y];
    while (i <= n && a[c1[i]].first <= b[x])
      s.insert(pair<long long, long long>(a[c1[i]].second, c1[i])), i++;
    if (s.size()) {
      pair<long long, long long> d = *s.rbegin();
      j[w] = pair<long long, long long>(d.second, x);
      w++;
      sum += d.first;
      s.erase(d);
    }
  }
  cout << w << ' ' << sum << endl;
  for (long long y = 0; y < w; y++)
    cout << j[y].first << ' ' << j[y].second << endl;
}
