#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1100;
pair<int, int> mesa[MAXN];
pair<pair<int, int>, int> grupo[MAXN];
vector<pair<int, int> > v;
bool mrk[MAXN];
int N, K;
void solve() {
  int resp = 0, qtd = 0;
  sort(mesa + 1, mesa + K + 1);
  sort(grupo + 1, grupo + N + 1);
  int ult = 0;
  for (int i = 1; i <= K; i++) {
    int maxi = -1;
    for (int k = 1; k <= N; k++) {
      if (grupo[k].first.first > mesa[i].first) break;
      if (!mrk[k] &&
          (maxi == -1 || grupo[k].first.second >= grupo[maxi].first.second))
        maxi = k;
    }
    if (maxi != -1) {
      qtd++;
      resp += grupo[maxi].first.second;
      mrk[maxi] = true;
      v.push_back(make_pair(grupo[maxi].second, mesa[i].second));
    }
  }
  sort(v.begin(), v.end());
  printf("%d %d\n", qtd, resp);
  for (int i = 0; i < qtd; i++) printf("%d %d\n", v[i].first, v[i].second);
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d %d", &(grupo[i].first).first, &(grupo[i].first).second);
    grupo[i].second = i;
  }
  scanf("%d", &K);
  for (int i = 1; i <= K; i++) {
    scanf("%d", &mesa[i].first);
    mesa[i].second = i;
  }
  solve();
  return 0;
}
