#include <bits/stdc++.h>
using namespace std;
const int N = 100;
int n, k, q, a[N];
bool vis[N];
vector<int> v;
int main() {
  scanf("%d%d", &n, &k);
  int m = n / k;
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  scanf("%d", &q);
  while (q--) {
    int sum = 0;
    for (int i = 0, x; i < m; ++i) {
      scanf("%d", &x);
      --x;
      sum += a[x];
      vis[x] = true;
    }
    v.push_back(sum);
  }
  sort(v.begin(), v.end());
  int mn = 2e9, mx = 0, out = n - k * m;
  if (!v.empty()) {
    mn = v[0];
    mx = v.back();
  }
  vector<int> vv;
  for (int i = 0; i < n; ++i)
    if (!vis[i]) vv.push_back(a[i]);
  if ((int)vv.size() - m >= out) {
    sort(vv.begin(), vv.end());
    int sum = 0;
    for (int i = 0; i < m; ++i) sum += vv[i];
    mn = min(mn, sum);
    int need = m;
    sum = 0;
    while (need--) {
      sum += vv.back();
      vv.pop_back();
    }
    mx = max(mx, sum);
  }
  printf("%.10lf %.10lf\n", mn * 1.0 / m, mx * 1.0 / m);
  return 0;
}
