#include <bits/stdc++.h>
using namespace std;
typedef int arr[5001];
typedef pair<int, int> arr_pair[5001];
typedef int matrix[50001][10];
const int base = 1e9 + 7;
void panic(int x) {
  cout << x;
  exit(0);
  return;
}
int main() {
  int n, k;
  arr ans = {0}, c, p, comp;
  arr_pair r;
  bool used[5001];
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d %d", &c[i], &p[i]);
  cin >> k;
  for (int i = 0; i < k; i++) {
    scanf("%d", &r[i].first);
    r[i].second = i;
  }
  for (int i = 0; i < n; i++) {
    used[i] = false;
    comp[i] = -1;
  }
  sort(r, r + k);
  for (int i = 0; i < k; i++) {
    int maxi = -1, max_v = 0;
    for (int j = 0; j < n; j++)
      if (c[j] <= r[i].first && p[j] > max_v && (!used[j])) {
        max_v = p[j];
        maxi = j;
      }
    if (maxi != -1) {
      ans[maxi] = max_v;
      comp[maxi] = r[i].second;
      used[maxi] = true;
    }
  }
  int res = 0, m = 0;
  for (int i = 0; i < n; i++)
    if (comp[i] >= 0) {
      res += ans[i];
      m++;
    }
  cout << m << " " << res << endl;
  for (int i = 0; i < n; i++)
    if (comp[i] >= 0) printf("%d %d\n", i + 1, comp[i] + 1);
  return 0;
}
