#include <bits/stdc++.h>
using namespace std;
bool mark[131];
int num[131];
int n, k, q;
double mx = 0, mn = 100 * 100 * 100;
int main() {
  cin >> n >> k;
  int n_card = k;
  k = n / k;
  for (int i = 0; i < n; i++) cin >> num[i];
  cin >> q;
  for (int i = 0; i < q; i++) {
    double p = 0;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      a--;
      mark[a] = true;
      p += num[a];
    }
    p /= double(k);
    mn = min(mn, p);
    mx = max(mx, p);
  }
  vector<int> v;
  for (int i = 0; i < n; i++)
    if (mark[i] == false) v.push_back(num[i]);
  if (v.size() >= k && (n - v.size()) / k < n_card) {
    sort(v.begin(), v.end());
    double MX = 0, MN = 0;
    for (int i = 0; i < k; i++) MX += v[v.size() - i - 1];
    for (int i = 0; i < k; i++) MN += v[i];
    mn = min(mn, MN / double(k));
    mx = max(mx, MX / double(k));
  }
  cout << fixed << setprecision(10) << mn << " " << mx << endl;
  return 0;
}
