#include <bits/stdc++.h>
int l, z = 0;
int cmp(const void *a, const void *b) {
  int a1 = *(int *)a;
  int b1 = *(int *)b;
  return a1 - b1;
}
int main() {
  int min = 1000000, max = 0, t = 1;
  int n, k, a[100], q;
  scanf("%i%i", &n, &k);
  l = n / k;
  for (int i = 0; i < n; i++) scanf("%i", &a[i]);
  scanf("%i", &q);
  for (int i = 0; i < q; i++) {
    int p = 0, s = 0, s1;
    for (int j = 0; j < l; j++) {
      scanf("%i", &s1);
      s += a[s1 - 1];
      if (a[s1 - 1] < 0) p = 1;
      a[s1 - 1] = -1;
    }
    if (p) continue;
    z += l;
    if (t) {
      t = 0;
      min = s;
      max = s;
    }
    if (s > max) max = s;
    if (s < min) min = s;
  }
  qsort(a, n, sizeof(int), cmp);
  if (n - z >= l && z / l < k) {
    int max1 = 0, min1 = 0;
    for (int i = z; i <= z + l - 1; i++) min1 += a[i];
    for (int i = n - l; i <= n - 1; i++) max1 += a[i];
    if (max1 > max) max = max1;
    if (min1 < min) min = min1;
  }
  printf("%0.6f %0.6f", min * 1.0 / l, max * 1.0 / l);
}
