#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
inline void INP() {}
bool check(string &s) {
  int i = 0, j = s.length() - 1;
  while (i <= j) {
    if (s[i] != s[j]) return false;
    i++;
    j--;
  }
  return true;
}
int binary(vector<pair<int, int>> &tables, int num) {
  int i = 0, j = tables.size() - 1;
  int ans = tables.size();
  while (i <= j) {
    int mid = (i + j) / 2;
    int value = tables[mid].first;
    if (value < num) {
      i = mid + 1;
    } else {
      ans = mid;
      j = mid - 1;
    }
  }
  return ans;
}
void solve() {
  int n;
  cin >> n;
  vector<pair<int, pair<int, int>>> v;
  for (int i = 0; i < (n); ++i) {
    int c, p;
    cin >> c >> p;
    v.push_back(make_pair(p, make_pair(c, i)));
  }
  sort(v.begin(), v.end(), greater<pair<int, pair<int, int>>>());
  int k;
  cin >> k;
  vector<pair<int, int>> tables(k);
  for (int i = 0; i < (k); ++i) {
    int a;
    cin >> a;
    tables[i] = make_pair(a, (int)i);
  }
  sort(tables.begin(), tables.end());
  int index[k];
  for (int i = 0; i < (k); ++i) index[i] = -1;
  for (int i = 0; i < (v.size()); ++i) {
    int idx = v[i].second.second;
    int size = v[i].second.first;
    int pos = binary(tables, size);
    if (pos != tables.size()) {
      if (index[tables[pos].second] == -1) {
        index[tables[pos].second] = i;
      } else {
        while (pos < tables.size() && index[tables[pos].second] != -1) {
          pos++;
        }
        if (pos != tables.size()) {
          if (index[tables[pos].second] == -1) {
            index[tables[pos].second] = i;
          }
        }
      }
    }
  }
  int count = 0;
  int money = 0;
  for (int i = 0; i < (k); ++i) {
    if (index[i] != -1) {
      count++;
      money += v[index[i]].first;
    }
  }
  cout << count << " ";
  cout << money << '\n';
  for (int i = 0; i < (k); ++i) {
    if (index[i] != -1) {
      cout << v[index[i]].second.second + 1 << " ";
      cout << i + 1 << '\n';
    }
  }
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
