#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  pair<int, pair<int, int> > g[1000];
  pair<int, pair<int, int> > t[1000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> g[i].second.first >> g[i].first;
    g[i].second.second = i + 1;
  }
  sort(g, g + n);
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> t[i].first;
    t[i].second.first = -1;
    t[i].second.second = i + 1;
  }
  sort(t, t + m);
  int r = 0, sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < m; j++) {
      if (g[i].second.first <= t[j].first && t[j].second.first == -1) {
        r++;
        sum += g[i].first;
        t[j].second.first = g[i].second.second;
        t[j].first = t[j].second.second;
        break;
      }
    }
  }
  cout << r << " " << sum << endl;
  for (int i = 0; i < m; i++) {
    if (t[i].second.first != -1) {
      cout << t[i].second.first << " " << t[i].first << endl;
    }
  }
  return 0;
}
