#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
const long long INF64 = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
int n, k;
int a[200];
int was[200];
void Load() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
}
void Solve() {
  int q, kol;
  kol = n / k;
  cin >> q;
  long double mn = 1e42;
  long double mx = -1e42;
  for (int t = 0; t < q; t++) {
    long double cur = 0;
    int x;
    for (int i = 0; i < kol; i++) {
      cin >> x;
      cur += a[x];
      was[x] = 1;
    }
    mn = min(mn, cur / (long double)kol);
    mx = max(mx, cur / (long double)kol);
  }
  int ccc = 0;
  for (int i = 1; i <= n; i++) ccc += was[i];
  if (k * kol != ccc) {
    long double cur = 0;
    for (int t = 1; t <= kol; t++) {
      int Mx = -INF;
      int j = -1;
      for (int i = 1; i <= n; i++)
        if (was[i] != 1 && was[i] != 2 && a[i] > Mx) {
          Mx = a[i];
          j = i;
        }
      cur += Mx;
      was[j] = 2;
    }
    mx = max(mx, cur / (long double)kol);
    cur = 0;
    for (int t = 1; t <= kol; t++) {
      int Mn = INF;
      int j = -1;
      for (int i = 1; i <= n; i++)
        if (was[i] != 1 && was[i] != 3 && a[i] < Mn) {
          Mn = a[i];
          j = i;
        }
      cur += Mn;
      was[j] = 3;
    }
    mn = min(mn, cur / (long double)kol);
  }
  cout.setf(ios::fixed | ios ::showpoint);
  cout.precision(10);
  cout << mn << " " << mx;
}
int main() {
  Load();
  Solve();
  return 0;
}
