#include <bits/stdc++.h>
using namespace std;
int vis[1005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  pair<int, pair<int, int>> pr[n];
  for (int i = 0; i < n; i++) {
    cin >> pr[i].first >> pr[i].second.first;
    pr[i].second.second = i;
  }
  sort(pr, pr + n);
  int k;
  cin >> k;
  pair<int, int> r[k];
  for (int i = 0; i < k; i++) {
    cin >> r[i].first;
    r[i].second = i;
  }
  sort(r, r + k);
  vector<pair<int, int>> res;
  int acr = 0, tom = 0;
  for (int i = 0; i < k; i++) {
    int mx = 0, cur = r[i].first, idx = 0;
    for (int j = 0; j < n; j++) {
      if (cur < pr[j].first) {
        break;
      }
      if (vis[j]) {
        continue;
      }
      if (pr[j].second.first > mx) {
        mx = pr[j].second.first;
        idx = j;
      }
    }
    if (mx) {
      vis[idx]++;
      res.push_back(make_pair(pr[idx].second.second + 1, r[i].second + 1));
      acr++;
      tom += mx;
    }
  }
  cout << acr << " " << tom << endl;
  for (int i = 0; i < acr; i++) {
    cout << res[i].first << " " << res[i].second << endl;
  }
  return 0;
}
