#include <bits/stdc++.h>
using namespace std;
struct vi {
  int n, p, i;
};
bool operator<(vi a, vi b) {
  if (a.p > b.p) return 1;
  return 0;
}
int main() {
  int n, k;
  cin >> n;
  vi vis[n];
  for (int i = 0; i < n; i++) {
    cin >> vis[i].n >> vis[i].p;
    vis[i].i = i;
  }
  cin >> k;
  vector<int> tables(k);
  for (int i = 0; i < k; i++) {
    cin >> tables[i];
  }
  bool v[k];
  memset(v, 0, sizeof v);
  sort(vis, vis + n);
  int cnt = 0, ans = 0;
  vector<pair<int, int> > ans2;
  for (int i = 0; i < n; i++) {
    int x = vis[i].n;
    bool f = 0;
    int xx = 1000000;
    int in;
    int last = -1;
    for (int j = 0; j < k; j++) {
      if (tables[j] >= x and v[j] == 0) {
        if (tables[j] < xx) {
          xx = tables[j];
          f = 1;
          in = j + 1;
          v[j] = 1;
          if (last != -1) {
            v[last] = 0;
          }
          last = j;
        }
      }
    }
    if (f) {
      cnt++;
      ans += vis[i].p;
      pair<int, int> h(vis[i].i + 1, in);
      ans2.push_back(h);
    }
  }
  cout << cnt << " " << ans << endl;
  for (int i = 0; i < ans2.size(); i++) {
    cout << ans2[i].first << " " << ans2[i].second << endl;
  }
}
