#include <bits/stdc++.h>
using namespace std;
int r[100005] = {0};
pair<pair<int, int>, int> grp[100005];
vector<pair<int, int> > res;
bool cmp(pair<pair<int, int>, int> x, pair<pair<int, int>, int> y) {
  return (x.second < y.second);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int i, j, min, k, x, y, ans;
  for (i = 1; i <= n; i++) {
    cin >> x >> y;
    grp[i] = {{i, x}, y};
  }
  cin >> k;
  for (j = 1; j <= k; j++) {
    cin >> r[j];
  }
  sort(grp + 1, grp + n + 1, cmp);
  ans = 0;
  for (i = n; i >= 1; i--) {
    min = 0;
    r[min] = INT_MAX;
    for (j = 1; j <= k; j++) {
      if (r[j] >= grp[i].first.second) {
        if (r[min] > r[j]) {
          min = j;
        }
      }
    }
    if (min != 0) {
      res.push_back({grp[i].first.first, min});
      ans = ans + grp[i].second;
      r[min] = 0;
    }
  }
  cout << res.size() << " " << ans << "\n";
  for (auto it : res) {
    cout << it.first << " " << it.second << "\n";
  }
  return 0;
}
