#include <bits/stdc++.h>
using namespace std;
std::vector<long long> prime;
unsigned long long int power(unsigned long long int x, unsigned long long int y,
                             unsigned long long int mod) {
  unsigned long long int res = 1;
  while (y) {
    if (y & 1) res = res * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return res;
}
bool miller(unsigned long long int x, unsigned long long int d) {
  unsigned long long int a = rand() % (x - 1) + 2;
  unsigned long long int ad = power(a, d, x);
  if (ad == 1 || ad == x - 1) {
    return true;
  }
  while (d != x - 1) {
    ad = ad * ad % x;
    if (ad == 1) {
      return false;
    }
    if (ad == x - 1) {
      return true;
    }
    d *= 2;
  }
  return false;
}
bool primer(unsigned long long int x) {
  if (x == 2 || x == 3 || x == 5 || x == 7) return true;
  if (x % 2 == 0 || x == 1) return false;
  unsigned long long int d = x - 1;
  while (d % 2 == 0) d = d / 2;
  for (int i = 0; i < 7; ++i) {
    if (!miller(x, d)) {
      return false;
    }
  }
  return true;
}
bool isp(long long n) {
  if (n == 1) {
    return false;
  }
  for (int i = 2; i <= sqrt(n); i++) {
    if (!n % 2) {
      return false;
    }
  }
  return true;
}
int nearestprime(unsigned long long int x) {
  unsigned long long int i;
  for (i = x; !primer(i); i--)
    ;
  return i;
}
set<pair<int, int> > st;
int main() {
  ios::sync_with_stdio(false);
  int n, k, c, p;
  int tsize[1000 + 45];
  pair<int, pair<int, int> > price[1000 + 45];
  bool occ[1000 + 45];
  for (int i = 0; i <= 1000; i++) {
    occ[i] = false;
  }
  vector<pair<int, int> > ans;
  pair<int, int> table[1000 + 45];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c >> p;
    price[i].first = p;
    price[i].second.first = INT_MAX - c;
    price[i].second.second = i;
  }
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> table[i].first;
    table[i].second = i;
  }
  pair<int, int> *it;
  sort(price, price + n);
  sort(table, table + k);
  table[k].first = INT_MAX;
  table[k].second = INT_MAX;
  long long sum = 0;
  int cnt = 0;
  for (int i = n - 1; i >= 0; i--) {
    it = lower_bound(table, table + k,
                     make_pair(INT_MAX - price[i].second.first, -1));
    if (it->first == INT_MAX) {
      continue;
    } else {
      bool flag = true;
      while (occ[it->second] == true) {
        it++;
        if (it->first == INT_MAX) {
          flag = false;
          break;
        }
      }
      if (flag == true) {
        occ[it->second] = true;
        sum += price[i].first;
        cnt++;
        ans.push_back(make_pair(price[i].second.second, it->second));
      }
    }
  }
  cout << cnt << " " << sum << "\n";
  sort(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first + 1 << " " << ans[i].second + 1 << "\n";
  }
  return 0;
}
