#include <bits/stdc++.h>
using namespace std;
int n, k, q;
double a[110];
bool used[110];
double score(vector<int>& idx) {
  double res = 0;
  for (int i = 0; i < idx.size(); ++i) {
    res += a[idx[i]];
  }
  return res / (1.0 * idx.size());
}
map<vector<int>, bool> was;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> q;
  int m = n / k;
  double mx = 0;
  double mn = 100000;
  memset(used, 0, sizeof(used));
  for (int i = 0; i < q; i++) {
    vector<int> v(m);
    for (int j = 0; j < m; j++) {
      cin >> v[j];
      v[j]--;
      used[v[j]] = true;
    }
    double s = score(v);
    sort(v.begin(), v.end());
    was[v] = true;
    mx = max(mx, s);
    mn = min(mn, s);
  }
  vector<double> us;
  for (int i = 0; i < n; i++)
    if (!used[i]) us.push_back(a[i]);
  sort(us.begin(), us.end());
  if (us.size() >= m && was.size() < k) {
    double x = 0;
    for (int i = 0; i < m; i++) {
      x += us[us.size() - i - 1];
    }
    mx = max(x / m, mx);
    x = 0;
    for (int i = 0; i < m; i++) {
      x += us[i];
    }
    mn = min(x / m, mn);
  }
  printf("%.6lf %.6lf\n", mn, mx);
  return 0;
}
