#include <bits/stdc++.h>
using namespace std;
void calc(int n, int k, vector<int> &pro) {
  int l = n / k;
  sort(pro.begin(), pro.end());
  double avg1 = 0, avg2 = 0;
  for (int i = (0); i <= (l - 1); i++) {
    avg1 += pro[i];
  }
  int kk = pro.size() - 1;
  for (int i = (kk); i >= (kk - l + 1); i--) {
    avg2 += pro[i];
  }
  printf("%.10lf %.10lf\n", avg1 / l, avg2 / l);
  return;
}
int main() {
  vector<int> pro;
  int n, k, temp;
  cin >> n >> k;
  for (int i = (0); i <= (n - 1); i++) {
    cin >> temp;
    pro.push_back(temp);
  }
  int q, r, l = n / k;
  vector<double> avg;
  set<int> remov;
  bool used[200] = {0};
  cin >> q;
  r = q;
  if (!q) {
    calc(n, k, pro);
    return 0;
  }
  for (int i = (1); i <= (q); i++) {
    double tavg = 0;
    for (int i = (1); i <= (l); i++) {
      cin >> temp;
      if (used[temp]) r--;
      used[temp] = 1;
      tavg += pro[temp - 1];
      remov.insert(temp - 1);
    }
    avg.push_back(tavg / l);
  }
  sort(avg.begin(), avg.end());
  vector<int> neew;
  for (int i = (0); i <= (n - 1); i++) {
    if (remov.find(i) == remov.end()) neew.push_back(pro[i]);
  }
  if (neew.size() < l || r == k) {
    printf("%.10lf %.10lf", avg[0], avg[q - 1]);
    return 0;
  }
  sort(neew.begin(), neew.end());
  double avg1 = 0, avg2 = 0;
  for (int i = (0); i <= (l - 1); i++) {
    avg1 += neew[i];
  }
  avg1 /= l;
  int kk = neew.size() - 1;
  for (int i = (kk); i >= (kk - l + 1); i--) {
    avg2 += neew[i];
  }
  avg2 /= l;
  if (avg1 < avg[0])
    printf("%.10lf", avg1);
  else
    printf("%.10lf", avg[0]);
  cout << " ";
  if (avg2 < avg[q - 1])
    printf("%.10lf", avg[q - 1]);
  else
    printf("%.10lf", avg2);
  cout << endl;
  return 0;
}
