#include <bits/stdc++.h>
using namespace std;
int ar[1002], pr[1002], ap[1002], ta[1002], tb[1002], ans, flag[1009];
struct data {
  int a, s, d;
};
vector<data> vec;
struct tab {
  int a, s;
};
vector<tab> vecc;
bool comp(data qq, data ww) {
  if (qq.s == ww.s) return qq.a < ww.a;
  return -qq.s < -ww.s;
}
bool compp(tab zz, tab xx) { return zz.a < xx.a; }
vector<int> ve, vee;
int main() {
  int a, s, d, f, g, h, j, k, l, low, high;
  cin >> a;
  for (s = 1; s <= a; s++) {
    cin >> k >> l;
    data aa;
    aa.a = k;
    aa.s = l;
    aa.d = s;
    vec.push_back(aa);
  }
  sort(vec.begin(), vec.end(), comp);
  for (s = 1; s <= a; s++) {
    data aa;
    aa = vec[s - 1];
    ar[s] = aa.a;
    pr[s] = aa.s;
    ap[s] = aa.d;
  }
  cin >> d;
  for (s = 1; s <= d; s++) {
    cin >> k;
    tab ss;
    ss.a = k;
    ss.s = s;
    vecc.push_back(ss);
  }
  sort(vecc.begin(), vecc.end(), compp);
  for (s = 1; s <= d; s++) {
    tab ss;
    ss = vecc[s - 1];
    ta[s] = ss.a;
    tb[s] = ss.s;
  }
  for (s = 1; s <= a; s++) {
    for (f = 1; f <= d; f++) {
      if (flag[f] == 0) {
        if (ar[s] <= ta[f]) {
          flag[f] = 1;
          ans = ans + pr[s];
          ve.push_back(ap[s]);
          vee.push_back(tb[f]);
          break;
        }
      }
    }
  }
  cout << ve.size() << " " << ans << endl;
  for (g = 0; g < ve.size(); g++) cout << ve[g] << " " << vee[g] << endl;
  return 0;
}
