#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, q;
  scanf("%d%d", &n, &k);
  int a[100];
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  scanf("%d", &q);
  int cnt = n / k;
  bool check[100] = {false};
  double minv = 1e100, maxv = -1e100;
  set<vector<int> > S;
  for (int i = 0; i < q; i++) {
    int sum = 0;
    vector<int> tmp;
    for (int j = 0; j < cnt; j++) {
      int x;
      scanf("%d", &x);
      x--;
      check[x] = true;
      sum += a[x];
      tmp.push_back(x);
    }
    minv = min(minv, (double)sum / cnt);
    maxv = max(maxv, (double)sum / cnt);
    sort(tmp.begin(), tmp.end());
    S.insert(tmp);
  }
  vector<int> L;
  for (int i = 0; i < n; i++)
    if (!check[i]) L.push_back(a[i]);
  sort(L.begin(), L.end());
  if (L.size() >= cnt && S.size() < k) {
    int sum = 0;
    for (int i = 0; i < cnt; i++) sum += L[i];
    minv = min(minv, (double)sum / cnt);
    sum = 0;
    for (int i = L.size() - cnt; i < L.size(); i++) sum += L[i];
    maxv = max(maxv, (double)sum / cnt);
  }
  printf("%.10lf %.10lf\n", minv, maxv);
  return 0;
}
