#include <bits/stdc++.h>
using namespace std;
int a[105];
int sc[105];
int fl[105];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int i;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  int q;
  scanf("%d", &q);
  int ty = n / k;
  int j, x;
  int mi1, ma1;
  mi1 = ma1 = -1;
  while (q--) {
    int cur = 0;
    for (i = 0; i < ty; i++) {
      scanf("%d", &x);
      fl[x] = 1;
      cur += a[x];
    }
    if (mi1 == -1) mi1 = cur;
    if (cur < mi1) mi1 = cur;
    if (ma1 == -1) ma1 = cur;
    if (cur > ma1) ma1 = cur;
  }
  vector<int> v;
  int done = 0;
  for (i = 1; i <= n; i++)
    if (fl[i] == 0)
      v.push_back(a[i]);
    else
      done++;
  sort(v.begin(), v.end());
  int mi = 0;
  int ma = 0;
  if (v.size() && done < ty * k) {
    for (i = 0; i < ty; i++) {
      mi += v[i];
      ma += v[v.size() - 1 - i];
    }
    if (mi1 == -1) mi1 = mi;
    if (ma1 == -1) ma1 = ma;
    mi = min(mi1, mi);
    ma = max(ma1, ma);
  } else {
    ma = ma1;
    mi = mi1;
  }
  printf("%.9f %.9f\n", (mi * 1.0) / ty, (ma * 1.0) / ty);
  return 0;
}
