#include <bits/stdc++.h>
using namespace std;
int k, n, a[105];
bool flag[105];
double minV, maxV;
int q;
int main() {
  memset(flag, false, sizeof(flag));
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i - 1]);
  scanf("%d", &q);
  maxV = 0.0;
  minV = 1000000.0;
  int nQues = n / k;
  for (int i = 1; i <= q; ++i) {
    int sumA = 0;
    int val;
    for (int j = 1; j <= nQues; ++j) {
      scanf("%d", &val);
      flag[val - 1] = true;
      sumA += a[val - 1];
    }
    double avg = sumA * 1.0 / nQues;
    maxV = max(maxV, avg);
    minV = min(minV, avg);
  }
  vector<int> b;
  for (int i = 0; i <= n - 1; ++i) {
    if (!flag[i]) {
      b.push_back(a[i]);
    }
  }
  sort(b.begin(), b.end());
  int len = b.size();
  if (len >= nQues && len > (n - n / k * k)) {
    int sumA = 0;
    for (int i = 0; i <= nQues - 1; ++i) {
      sumA += b[i];
    }
    double avg = sumA * 1.0 / nQues;
    maxV = max(maxV, avg);
    minV = min(minV, avg);
    sumA = 0;
    for (int i = len - 1; i >= (len - nQues); i--) {
      sumA += b[i];
    }
    avg = sumA * 1.0 / nQues;
    maxV = max(maxV, avg);
    minV = min(minV, avg);
  }
  printf("%.9lf %.9lf", minV, maxV);
  return 0;
}
