#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
int main() {
  int n, k, a[101], q, s[101], sum = 0;
  double minimum, maximum;
  bool f[101];
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  scanf("%d", &q);
  minimum = 100;
  maximum = 0;
  memset(f, 0, sizeof(f));
  for (int i = 1; i <= q; i++) {
    int u;
    double v = 0;
    for (int j = 1; j <= n / k; j++) {
      scanf("%d", &u);
      v += a[u];
      f[u] = 1;
    }
    double m = v / (n / k);
    if (m < minimum) minimum = m;
    if (m > maximum) maximum = m;
  }
  for (int i = 1; i <= n; i++)
    if (!f[i]) s[sum++] = a[i];
  if (n / k != (n - sum) / k && sum >= n / k) {
    double v = 0, m;
    sort(s, s + sum);
    for (int i = 0; i < n / k; i++) v += s[i];
    m = v / (n / k);
    if (m < minimum) minimum = m;
    if (m > maximum) maximum = m;
    v = 0;
    for (int i = 0; i < n / k; i++) v += s[sum - 1 - i];
    m = v / (n / k);
    if (m < minimum) minimum = m;
    if (m > maximum) maximum = m;
  }
  printf("%.10lf %.10lf\n", minimum, maximum);
  return 0;
}
