#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
bool comp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return a.first.second > b.first.second;
}
int run_test() {
  int n;
  cin >> n;
  vector<pair<pair<int, int>, int>> v(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    v[i] = {{a, b}, i + 1};
  }
  int k;
  cin >> k;
  vector<int> table(k), visited(k, 0);
  for (int i = 0; i < k; i++) {
    cin >> table[i];
  }
  sort(v.begin(), v.end(), comp);
  vector<pair<int, int>> ans;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    int cost = v[i].first.second;
    int req = v[i].first.first;
    int ind = v[i].second;
    int mini = 2001;
    int table_ind;
    for (int j = 0; j < k; j++) {
      if (!visited[j] && table[j] >= req) {
        if (table[j] < mini) {
          mini = table[j];
          table_ind = j;
        }
      }
    }
    if (mini >= req && mini != 2001) {
      visited[table_ind] = 1;
      ans.push_back({ind, table_ind + 1});
      sum += cost;
    }
  }
  cout << ans.size() << " " << sum << "\n";
  for (auto x : ans) {
    cout << x.first << " " << x.second << "\n";
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tt;
  tt = 1;
  while (tt--) {
    run_test();
  }
}
