#include <bits/stdc++.h>
using namespace std;
int n, m, k, a[111];
bool v[111] = {0};
int p[111], sz = 0;
;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  int num = n / k;
  int q;
  scanf("%d", &q);
  double a1 = 1e9, a2 = -1;
  for (int i = 0; i < q; i++) {
    double t = 0;
    for (int j = 0; j < num; j++) {
      int tmp;
      scanf("%d", &tmp);
      tmp--;
      t += a[tmp];
      v[tmp] = 1;
    }
    t /= num;
    a1 = min(a1, t);
    a2 = max(a2, t);
  }
  for (int i = 0; i < n; i++) {
    if (!v[i]) {
      p[sz++] = a[i];
    }
  }
  sort(p, p + sz);
  if (!(sz <= n - k * num)) {
    double t1 = 0, t2 = 0;
    for (int i = 0; i < num; i++) {
      t1 += p[i];
      t2 += p[sz - i - 1];
    }
    t1 /= num;
    t2 /= num;
    a1 = min(a1, t1);
    a2 = max(a2, t2);
  }
  printf("%.20f %.20f\n", a1 + 1e-12, a2 + 1e-12);
  return 0;
}
