#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const double eps = 1e-6;
int n, k, q, m;
int a[N], b[N], used[N];
double MinAns = 100.0, MaxAns = 0.0;
double max(double x, double y) { return x - eps >= y ? x : y; }
double min(double x, double y) { return x + eps <= y ? x : y; }
void init() {
  scanf("%d %d", &n, &k);
  m = n / k;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
}
void work() {
  int x, sum, cnt;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    sum = 0;
    for (int j = 1; j <= m; j++) {
      scanf("%d", &x);
      used[x] = 1;
      sum += a[x];
    }
    MinAns = min(MinAns, 1.0 * sum / m);
    MaxAns = max(MaxAns, 1.0 * sum / m);
  }
  cnt = 0;
  for (int i = 1; i <= n; i++)
    if (!used[i]) b[++cnt] = a[i];
  sort(b + 1, b + 1 + cnt);
  if (cnt >= m && n - cnt < k * m) {
    sum = 0;
    for (int i = 1; i <= m; i++) sum += b[i];
    MinAns = min(MinAns, 1.0 * sum / m);
    sum = 0;
    for (int i = cnt; i > cnt - m; i--) sum += b[i];
    MaxAns = max(MaxAns, 1.0 * sum / m);
  }
  printf("%.10lf %.10lf\n", MinAns, MaxAns);
}
int main() {
  init();
  work();
  return 0;
}
