#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, Q, A, B;
  double val[101];
  vector<double> v;
  cin >> N >> K;
  for (int i = 0; i < N; ++i) cin >> val[i];
  cin >> Q;
  double L = 0, U = 0;
  int count = 0;
  for (int i = 0; i < Q; ++i) {
    double tmp = 0;
    int t;
    for (int j = 0; j < N / K; ++j) {
      cin >> t;
      t--;
      tmp += val[t];
      val[t] = -1;
    }
    if (tmp >= 0) {
      count++;
      tmp = tmp / (double)(N / K);
      if (i == 0)
        L = U = tmp;
      else
        L = min(L, tmp), U = max(U, tmp);
    }
  }
  for (int i = 0; i < N; ++i)
    if (val[i] != -1) v.push_back(val[i]);
  sort(v.begin(), v.end());
  if (count < K) {
    double tmp = 0;
    for (int i = 0; i < N / K; ++i) tmp += v[i];
    tmp = tmp / (double)(N / K);
    if (Q == 0)
      L = tmp;
    else
      L = min(L, tmp);
    tmp = 0;
    for (int i = 0; i < N / K; ++i) tmp += v[v.size() - 1 - i];
    tmp = tmp / (double)(N / K);
    if (Q == 0)
      U = tmp;
    else
      U = max(U, tmp);
  }
  printf("%.10lf %.10lf\n", L, U);
  return 0;
}
