#include <bits/stdc++.h>
using namespace std;
void oinp() { freopen("a.inp", "r", stdin); }
void oout() { freopen("a.out", "w", stdout); }
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int n, a[1000000], k, h, q, j, x, i;
bool v[1000000];
int main() {
  cin >> n >> k;
  int nn = n;
  h = n / k;
  for (i = 1; i <= n; i++) cin >> a[i];
  cin >> q;
  double minres = 1000000000.0;
  double maxres = 0.0;
  double mres;
  memset(v, false, sizeof(v));
  for (i = 1; i <= q; i++) {
    mres = 0.0;
    for (j = 1; j <= h; j++) {
      scanf("%ld", &x);
      v[x] = true;
      mres += (double)a[x];
    }
    if (minres > mres) minres = mres;
    if (maxres < mres) maxres = mres;
  }
  j = 0;
  for (i = 1; i <= n; i++)
    if (v[i] == false) {
      j++;
      a[j] = a[i];
    }
  n = j;
  sort(a + 1, a + n + 1);
  if (n == nn - (nn / k) * k) n = 0;
  double res1 = minres / (double)h;
  if (n >= h) {
    minres = 0;
    for (i = 1; i <= h; i++) {
      minres += (double)a[i];
    }
  } else
    minres = 1000000000.0;
  double res2 = maxres / (double)h;
  if (n >= h) {
    maxres = 0;
    for (i = n - h + 1; i <= n; i++) maxres += (double)a[i];
  } else
    maxres = -1000000.0;
  cout << fixed << setprecision(9) << min(res1, minres / (double)h) << " ";
  cout << fixed << setprecision(9) << max(res2, maxres / (double)h);
}
