#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int> > v;
const int MAX = 10e3 + 13;
vector<pair<int, int> > t;
int ans[MAX];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    v.push_back(make_pair(make_pair(b, a), i + 1));
  }
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    int a;
    cin >> a;
    t.push_back(make_pair(a, i + 1));
  }
  sort(t.begin(), t.end());
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  int s = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) {
      if (v[i].first.second <= t[j].first && ans[j] == 0) {
        ans[j] = v[i].second;
        s += v[i].first.first;
        break;
      }
    }
  }
  int m = 0;
  for (int i = 0; i < k; i++) {
    if (ans[i] != 0) m++;
  }
  cout << m << " " << s << endl;
  for (int i = 0; i < k; i++) {
    if (ans[i] != 0) {
      cout << ans[i] << " " << t[i].second << endl;
    }
  }
  return 0;
}
