#include <bits/stdc++.h>
using namespace std;
int visited[103];
int pro[103];
vector<int> mypro;
vector<double> mepro;
int main() {
  int n, k;
  cin >> n >> k;
  int ncard = n / k;
  for (int i = 1; i <= n; i++) {
    cin >> pro[i];
  }
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int tmp, j, tmp2 = 0;
    for (j = 1; j <= ncard; j++) {
      cin >> tmp;
      if (visited[tmp] == 1) {
        for (int k = 2; k <= ncard; k++) cin >> tmp;
        break;
      }
      visited[tmp] = 1;
      tmp2 += pro[tmp];
    }
    if (j != ncard + 1) continue;
    mepro.push_back(tmp2 / double(ncard));
  }
  if (mepro.size() < k) {
    for (int i = 1; i <= n; i++) {
      if (!visited[i]) {
        mypro.push_back(pro[i]);
      }
    }
    sort(mypro.begin(), mypro.end());
    int mi = 0, ma = 0;
    for (int i = 0; i < (ncard); i++) {
      mi += mypro[i];
    }
    int sz = mypro.size();
    for (int i = sz - 1; i >= sz - (n / k); i--) {
      ma += mypro[i];
    }
    double res1 = mi / double(ncard);
    double res2 = ma / double(ncard);
    mepro.push_back(res1);
    mepro.push_back(res2);
  }
  sort(mepro.begin(), mepro.end());
  int sz1 = mepro.size();
  printf("%.10f %.10f", mepro[0], mepro[sz1 - 1]);
  return 0;
}
