#include <bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
const double eps = 1e-9;
int bil[105][105];
int g[105], b[105];
bool f[105];
int n, k, kol;
int main() {
  int i, j, sh;
  double sum;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d", &g[i]);
  }
  scanf("%d", &kol);
  sh = 0;
  for (i = 0; i < kol; i++) {
    for (j = 0; j < n / k; j++) {
      scanf("%d", &b[j]);
      b[j]--;
    }
    sort(b, b + (n / k));
    for (j = 0; j < sh; j++)
      if (b[0] == bil[j][0]) break;
    if (j == sh) {
      for (j = 0; j < n / k; j++) bil[sh][j] = b[j];
      sh++;
    }
  }
  for (i = 0; i < sh; i++) {
    for (j = 0; j < n / k; j++) {
      f[bil[i][j]] = true;
    }
  }
  double mn = inf, mx = -1;
  for (i = 0; i < sh; i++) {
    sum = 0;
    for (j = 0; j < n / k; j++) sum += g[bil[i][j]];
    sum /= double(n / k);
    if (sum - mx > eps) mx = sum;
    if (mn - sum > eps) mn = sum;
  }
  if (sh != k && n - sh * (n / k) >= n / k) {
    sh = 0;
    for (i = 0; i < n; i++) {
      if (!f[i]) {
        b[sh] = g[i];
        sh++;
      }
    }
    sort(b, b + sh);
    sum = 0;
    for (i = 0; i < n / k; i++) sum += b[i];
    sum /= double(n / k);
    if (sum - mx > eps) mx = sum;
    if (mn - sum > eps) mn = sum;
    sum = 0;
    for (i = 0; i < n / k; i++) sum += b[sh - 1 - i];
    sum /= double(n / k);
    if (sum - mx > eps) mx = sum;
    if (mn - sum > eps) mn = sum;
  }
  printf("%.15lf %.15lf", mn, mx);
  return 0;
}
