#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, a[200], q, card, m, cnt = 0;
  bool used[200] = {0};
  bool seen;
  double sum, ma = 0, mi = 100000, avg;
  scanf("%d%d", &n, &k);
  m = n / k;
  for (typeof(0) i = (0); i < (n); ++i) scanf("%d", &a[i]);
  scanf("%d", &q);
  for (typeof(0) i = (0); i < (q); ++i) {
    sum = 0;
    seen = false;
    for (typeof(0) j = (0); j < (m); ++j) {
      scanf("%d", &card);
      card--;
      if (used[card])
        seen = true;
      else
        used[card] = true;
      sum += a[card];
    }
    if (!seen) ++cnt;
    avg = sum / m;
    ma = max(ma, avg);
    mi = min(mi, avg);
  }
  vector<int> na;
  for (typeof(0) i = (0); i < (n); ++i)
    if (!used[i]) na.push_back(a[i]);
  if (cnt < k) {
    sort((na).rbegin(), (na).rend());
    sum = 0;
    for (typeof(0) i = (0); i < (m); ++i) sum += na[i];
    avg = sum / m;
    ma = max(ma, avg);
    sort((na).begin(), (na).end());
    sum = 0;
    for (typeof(0) i = (0); i < (m); ++i) sum += na[i];
    avg = sum / m;
    mi = min(mi, avg);
  }
  printf("%.8lf %.8lf\n", mi, ma);
  return 0;
}
