#include <bits/stdc++.h>
using namespace std;
class trip {
 public:
  long long first;
  long long second;
  long long third;
  trip() {}
};
bool comp1(trip a, trip b) {
  if (a.first == b.first) {
    if (a.second == b.second) {
      return a.third < b.third;
    }
    return a.second < b.second;
  }
  return a.first < b.first;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    long long n;
    cin >> n;
    vector<trip> v;
    for (int i = 0; i < n; i++) {
      trip p;
      cin >> p.first >> p.second;
      p.third = i + 1;
      v.push_back(p);
    }
    long long k;
    cin >> k;
    vector<pair<long long, long long> > r;
    for (int i = 0; i < k; i++) {
      pair<long long, long long> p;
      cin >> p.first;
      p.second = i + 1;
      r.push_back(p);
    }
    sort((v).begin(), (v).end(), comp1);
    sort((r).begin(), (r).end());
    vector<pair<long long, long long> > ans;
    long long sum = 0;
    for (int i = 0; i < k; i++) {
      long long mx = 0;
      long long in = -1;
      for (int j = 0; j < n; j++) {
        if (v[j].first > r[i].first) {
          break;
        } else {
          if (v[j].second > mx) {
            mx = v[j].second;
            in = j;
          }
        }
      }
      if (in != -1) {
        sum += v[in].second;
        pair<long long, long long> p;
        p.first = v[in].third;
        p.second = r[i].second;
        ans.push_back(p);
        v[in].second = -1;
      }
    }
    cout << ans.size() << " " << sum << "\n";
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i].first << " " << ans[i].second << "\n";
    }
  }
  return 0;
}
