#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, k, p, q;
  cin >> n >> k;
  p = n / k;
  vector<int> prof(n);
  for (int i = 0; i < (n); ++i) cin >> prof[i];
  cin >> q;
  vector<bool> mark(n, false);
  double minProf = numeric_limits<double>::max();
  double maxProf = 0;
  for (int i = 0; i < (q); ++i) {
    double average = 0;
    for (int j = 0; j < (p); ++j) {
      int index;
      cin >> index;
      --index;
      mark[index] = true;
      average += prof[index];
    }
    average /= p;
    minProf = min(minProf, average);
    maxProf = max(maxProf, average);
  }
  vector<int> remaining;
  for (int i = 0; i < (n); ++i)
    if (not mark[i]) remaining.push_back(prof[i]);
  int m = remaining.size();
  if (m >= p && n - m < k * p) {
    sort(remaining.begin(), remaining.end());
    double minMean = 0;
    double maxMean = 0;
    for (int i = 0; i < (p); ++i) {
      minMean += remaining[i];
      maxMean += remaining[m - i - 1];
    }
    minMean /= p;
    maxMean /= p;
    minProf = min(minProf, minMean);
    maxProf = max(maxProf, maxMean);
  }
  printf("%.10lf %.10lf\n", minProf, maxProf);
  return 0;
}
