#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
long long expo(long long n, long long m, long long p) {
  long long r = 1;
  n = n % p;
  while (m > 0) {
    if (m % 2) r = (r * n) % p;
    n = (n * n) % p;
    m = m / 2;
  }
  return r % p;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  vector<pair<long long, pair<long long, long long> > > v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i].second.first >> v[i].first;
    v[i].first = -1 * v[i].first;
    v[i].second.second = i;
  }
  long long k;
  cin >> k;
  vector<pair<long long, long long> > a(k);
  for (long long i = 0; i < k; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(v.begin(), v.end());
  sort(a.begin(), a.end());
  long long ans = 0;
  bool vis[k];
  long long an[n], a1 = 0;
  memset(an, -1, sizeof(an));
  memset(vis, false, sizeof(vis));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < k; j++) {
      if (vis[j]) continue;
      if (a[j].first >= v[i].second.first) {
        vis[j] = true;
        ans = ans - v[i].first;
        an[i] = a[j].second;
        a1++;
        break;
      }
    }
  }
  cout << a1 << ' ' << ans << endl;
  for (long long i = 0; i < n; i++) {
    if (an[i] != -1) {
      cout << v[i].second.second + 1 << ' ' << an[i] + 1 << endl;
    }
  }
}
