#include <bits/stdc++.h>
using namespace std;
int n, k, q;
int a[200], f[200], len, d;
int c[200], id[200];
double ans[200], x, y;
void gao() {
  sort(ans, ans + len);
  if (len == k) return;
  int i, j = 0;
  for (i = 0; i < n; i++)
    if (f[id[i]] == -1) {
      ans[len] += a[id[i]];
      j++;
      if (j == d) break;
    }
  ans[len++] /= d;
  j = 0;
  for (i = n - 1; i >= 0; i--)
    if (f[id[i]] == -1) {
      ans[len] += a[id[i]];
      j++;
      if (j == d) break;
    }
  ans[len++] /= d;
  sort(ans, ans + len);
}
bool cmp(int A, int B) { return a[A] < a[B]; }
int main() {
  int i, j;
  cin >> n >> k;
  d = n / k;
  for (i = 0; i < n; i++) cin >> a[i];
  cin >> q;
  memset(f, -1, sizeof(f));
  for (i = 0; i < q; i++) {
    for (j = 0; j < d; j++) cin >> c[j];
    for (j = 0; j < d; j++) c[j]--;
    if (f[c[0]] != -1) continue;
    for (j = 0; j < d; j++) f[c[j]] = len;
    ans[len] = 0;
    for (j = 0; j < d; j++) ans[len] += a[c[j]];
    ans[len] /= d;
    len++;
  }
  for (i = 0; i < n; i++) id[i] = i;
  sort(id, id + n, cmp);
  gao();
  printf("%.10lf %.10lf\n", ans[0], ans[len - 1]);
  return 0;
}
