#include <bits/stdc++.h>
const long long OO = 1e9;
const double EPS = (1e-7);
const int mxN = 2 * 1e5 + 9;
using namespace std;
bool compare(const pair<pair<int, int>, int>& i,
             const pair<pair<int, int>, int>& j) {
  return i.second < j.second;
}
bool compare2(const pair<int, int>& i, const pair<int, int>& j) {
  return i.second < j.second;
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int arr[mxN] = {0};
vector<pair<pair<int, int>, int>> v;
vector<pair<int, int>> t;
vector<pair<int, int>> ans;
bool vis[1000 + 9] = {0};
int main() {
  int n, k;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    cin >> x >> y;
    v.push_back(make_pair(make_pair(x, i), y));
  }
  sort(v.rbegin(), v.rend(), compare);
  cin >> k;
  for (int i = 1; i <= k; i++) {
    int x;
    cin >> x;
    t.push_back(make_pair(x, i));
  }
  sort(t.begin(), t.end());
  long long sum = 0, tot = 0;
  for (int i = 0; i < ((int)((v).size())); i++) {
    for (int j = 0; j < ((int)((t).size())); ++j) {
      if (v[i].first.first <= t[j].first && !vis[t[j].second]) {
        sum += v[i].second;
        tot++;
        vis[t[j].second] = true;
        ans.push_back(make_pair(v[i].first.second, t[j].second));
        break;
      }
    }
  }
  cout << tot << " " << sum << "\n";
  for (int i = 0; i < ((int)((ans).size())); i++) {
    cout << ans[i].first << " " << ans[i].second << "\n";
  }
  return 0;
}
