#include <bits/stdc++.h>
using namespace std;
const int N = 100;
vector<pair<int, int>> a;
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < int(n); i++) {
    int x;
    cin >> x;
    a.push_back(make_pair(x, 1));
  }
  double ans_min = 100000, ans_max = 0;
  int q;
  cin >> q;
  int count = 0;
  for (int i = 0; i < int(q); i++) {
    double cnt = 0, sum = 0;
    bool t = true;
    for (int j = 0; j < int(n / k); j++) {
      int x;
      cin >> x;
      if (a[x - 1].second == 1) {
        if (t) {
          count++;
          t = !t;
        }
        cnt++;
        sum += a[x - 1].first;
        a[x - 1].first = 200;
        a[x - 1].second = 0;
      }
    }
    ans_min = min(ans_min, sum / cnt);
    ans_max = max(ans_max, sum / cnt);
  }
  cout << setprecision(9) << fixed;
  if (count == k)
    cout << ans_min << " " << ans_max << endl;
  else {
    sort(a.begin(), a.end());
    int j = 0;
    while (j < n && a[j].first != 200) {
      j++;
    }
    int end_i = j;
    j = n / k;
    double sum = 0;
    for (int i = 0; i < int(j); i++) sum += a[i].first;
    double ans = sum / j;
    ans_min = min(ans_min, ans);
    sum = 0;
    for (int i = end_i - 1; i >= end_i - j; i--) {
      sum += a[i].first;
    }
    ans = sum / j;
    ans_max = max(ans, ans_max);
    cout << ans_min << " " << ans_max << endl;
  }
  return (0);
}
