#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  while (cin >> n >> k) {
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    bool used[n];
    memset(used, 0, sizeof(used));
    double minN = 1e50, maxN = 0;
    int w = n / k, q;
    cin >> q;
    for (int i = 0; i < q; i++) {
      double S = 0;
      for (int j = 0; j < w; j++) {
        int tmp;
        cin >> tmp;
        tmp--;
        S += v[tmp];
        used[tmp] = 1;
      }
      S /= w;
      minN = min(minN, S);
      maxN = max(maxN, S);
    }
    vector<int> tmp;
    for (int i = 0; i < n; i++)
      if (!used[i]) tmp.push_back(v[i]);
    sort(tmp.begin(), tmp.end());
    if (n - tmp.size() < k * w) {
      double S = 0;
      for (int i = 0; i < w; i++) S += tmp[i];
      S /= w;
      minN = min(minN, S);
      S = 0;
      for (int i = (int)tmp.size() - w; i < tmp.size(); i++) S += tmp[i];
      S /= w;
      maxN = max(maxN, S);
    }
    printf("%.10lf %.10lf\n", minN, maxN);
  }
  return 0;
}
