#include <bits/stdc++.h>
using namespace std;
double g[200];
int u[200];
bool mk[200];
bool cmp(const int a, const int b) { return g[a] < g[b]; }
int main() {
  int n, k, q, cart;
  scanf("%d %d", &n, &k);
  int t = n / k;
  double maxi = -200.0;
  double mini = 200.0;
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &g[i]);
    mk[i] = false;
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    double tmp = 0.0;
    for (int j = 0; j < t; j++) {
      scanf("%d", &cart);
      mk[cart] = true;
      tmp += g[cart];
    }
    tmp /= double(t);
    mini = min(mini, tmp);
    maxi = max(maxi, tmp);
  }
  int cont = 0;
  for (int i = 1; i <= n; i++) {
    if (!mk[i]) u[cont++] = i;
  }
  sort(u, u + cont, cmp);
  if (cont >= t && cont > n % k) {
    double ta = 0.0, tb = 0.0;
    for (int i = 0, j = cont - 1; i < t; i++, j--) {
      ta += g[u[i]];
      tb += g[u[j]];
    }
    ta /= double(t);
    tb /= double(t);
    mini = min(mini, ta);
    maxi = max(maxi, tb);
  }
  printf("%.10lf %.10lf\n", mini, maxi);
}
