#include <bits/stdc++.h>
using namespace std;
struct sss {
  int c, p, id, u;
} s[1005];
struct ss {
  int c, id;
} tb[1005];
int cmp(const sss& a, const sss& b) {
  if (a.c < b.c)
    return 1;
  else if (a.c == b.c) {
    if (a.p > b.p) return 1;
  }
  return 0;
}
int cmp1(const ss& a, const ss& b) {
  if (a.c < b.c)
    return 1;
  else if (a.c == b.c) {
    if (a.id > b.id) return 1;
  }
  return 0;
}
int main(void) {
  int n, k;
  scanf("%d", &n);
  int i;
  for (i = 0; i < n; i++) {
    scanf("%d %d", &s[i].c, &s[i].p);
    s[i].id = i;
    s[i].u = 0;
  }
  scanf("%d", &k);
  for (i = 0; i < k; i++) {
    scanf("%d", &tb[i].c);
    tb[i].id = i;
  }
  sort(s, s + n, cmp);
  sort(tb, tb + k, cmp1);
  int ans[1005], tot = 0, cnt = 0;
  for (i = 0; i < k; i++) ans[i] = -1;
  for (i = 0; i < k; i++) {
    int ff = -1, aa, j = 0;
    while (s[j].c <= tb[i].c && j < n) {
      if (s[j].p > ff && s[j].u == 0) ff = s[j].p, aa = j;
      j++;
    }
    if (ff != -1) ans[i] = aa, tot += ff, cnt++, s[aa].u = 1;
  }
  printf("%d %d\n", cnt, tot);
  for (i = 0; i < k; i++) {
    if (ans[i] != -1) {
      printf("%d %d\n", s[ans[i]].id + 1, tb[i].id + 1);
    }
  }
  return 0;
}
