#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, p, q, top = -1, max = -2, sum = 0;
  cin >> n;
  int arr[1001][2];
  int c[n][2];
  for (int i = 0; i < n; i++) cin >> c[i][0] >> c[i][1];
  int k;
  cin >> k;
  pair<int, int> r[k];
  for (int i = 0; i < k; i++) {
    cin >> p;
    r[i] = make_pair(p, i);
  }
  sort(r, r + k);
  for (int i = 0; i < k; i++) {
    max = 0;
    for (int j = 0; j < n; j++)
      if (c[j][0] <= r[i].first and c[j][1] > max and c[j][1])
        p = r[i].second + 1, q = j + 1, max = c[j][1];
    if (max) sum += max, arr[++top][0] = q, arr[top][1] = p, c[q - 1][1] = 0;
  }
  cout << top + 1 << " " << sum << endl;
  for (int i = 0; i <= top; i++) cout << arr[i][0] << " " << arr[i][1] << endl;
}
