#include <bits/stdc++.h>
using namespace std;
int n, k;
pair<int, int> g[1002];
pair<int, int> t[1002];
priority_queue<pair<int, int> > sol[1002];
vector<pair<int, int> > sol2;
long long money = 0;
bool used[1002];
int main() {
  ios::sync_with_stdio(false);
  memset(used, 0, sizeof(used));
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> g[i].first >> g[i].second;
  }
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> t[i].first;
    t[i].second = i;
  }
  sort(t, t + k);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) {
      if (g[i].first <= t[j].first) sol[j].push(make_pair((g[i].second), (i)));
    }
  }
  for (int i = 0; i < k; i++) {
    while (!sol[i].empty() && used[sol[i].top().second]) sol[i].pop();
    if (sol[i].empty()) continue;
    used[sol[i].top().second] = true;
    sol2.push_back(make_pair((sol[i].top().second), (t[i].second)));
    money += sol[i].top().first;
  }
  cout << sol2.size() << ' ' << money << '\n';
  for (size_t i = 0; i < sol2.size(); i++) {
    cout << sol2[i].first + 1 << ' ' << sol2[i].second + 1 << '\n';
  }
  return 0;
}
