#include <bits/stdc++.h>
using namespace std;
double ai[101];
bool mrk[101];
vector<double> vc;
int main() {
  int cnt = 0;
  double n, m;
  scanf("%lf %lf", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &ai[i]);
  }
  int q;
  scanf("%d", &q);
  double mx = 0.0;
  double mi = 100.0;
  double sum = 0, d = (int)(n / m);
  while (q--) {
    int c = 0;
    sum = 0;
    for (int i = 0; i < (int)d; i++) {
      int a;
      scanf("%d", &a);
      sum += ai[a];
      if (mrk[a] == 0) c = 1;
      mrk[a] = 1;
    }
    cnt += c;
    sum = sum / d;
    mx = max(mx, sum);
    mi = min(mi, sum);
  }
  for (int i = 1; i <= n; i++)
    if (mrk[i] == 0) vc.push_back(ai[i]);
  if ((vc.size() >= (int)d) && (cnt < m)) {
    sort(vc.begin(), vc.end());
    sum = 0;
    for (int i = 0; i < (int)d; i++) sum += vc[i];
    sum = sum / d * 1.0;
    mi = min(mi, sum);
    sum = 0;
    int A = vc.size() - (int)d;
    for (int i = vc.size() - 1; i >= A; i--) {
      sum += vc[i];
    }
    sum = sum / d * 1.0;
    mx = max(mx, sum);
  }
  printf("%.9f %.9f\n", mi, mx);
}
