#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, a[105], b[105], i, q, j, f, x, c = 0;
  double s = 0, s1 = 0, min = -1, max = -1;
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> a[i];
  cin >> q;
  for (i = 1; i <= q; i++) {
    f = 0;
    s = 0;
    for (j = 1; j <= n / k; j++) {
      cin >> x;
      if (a[x] == -1) {
        f = 1;
      }
      s = s + a[x];
      a[x] = -1;
    }
    if (f == 0) {
      c++;
      s = s / (n / k);
      if (i == 1) {
        min = s;
        max = s;
      } else {
        if (s < min)
          min = s;
        else if (s > max)
          max = s;
      }
    }
  }
  j = 0;
  for (i = 1; i <= n; i++) {
    if (a[i] != -1) b[j++] = a[i];
  }
  sort(b, b + j);
  if (j >= (n / k) && k - c >= 1) {
    s = 0;
    s1 = 0;
    for (i = 0; i < (n / k); i++) {
      s = s + b[i];
      s1 = s1 + b[j - 1 - i];
    }
    s = s / (n / k);
    s1 = s1 / (n / k);
    if (min == -1 && max == -1) {
      min = s;
      max = s1;
    } else {
      if (s < min) min = s;
      if (s1 > max) max = s1;
    }
  }
  printf("%0.10lf %0.10lf", min, max);
  return 0;
}
