#include <bits/stdc++.h>
using namespace std;
void RunProgram();
int main() { RunProgram(); }
int a[200], mark[200], n, m, k, q, sum, x, minS, maxS;
vector<int> t;
void RunProgram() {
  scanf("%d%d", &n, &k);
  m = n / k;
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  minS = (int)1e9;
  maxS = -minS;
  memset(mark, false, sizeof(mark));
  scanf("%d", &q);
  for (int loop = 0; loop < q; loop++) {
    sum = 0;
    for (int i = 0; i < m; i++) {
      scanf("%d", &x);
      sum += a[x];
      mark[x] = true;
    }
    minS = min(minS, sum);
    maxS = max(maxS, sum);
  }
  t.clear();
  for (int i = 1; i <= n; i++)
    if (!mark[i]) t.push_back(a[i]);
  if ((n - t.size()) / m < k) {
    sort(t.begin(), t.end());
    sum = 0;
    for (int i = 0; i < m; i++) sum += t[i];
    minS = min(minS, sum);
    maxS = max(maxS, sum);
    reverse(t.begin(), t.end());
    sum = 0;
    for (int i = 0; i < m; i++) sum += t[i];
    minS = min(minS, sum);
    maxS = max(maxS, sum);
  }
  printf("%.9lf %.9lf", (double)minS / m, (double)maxS / m);
}
