#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long linf = 1LL << 60;
const int maxn = 100 + 5;
int A[maxn];
bool used[maxn];
vector<int> Q;
vector<vector<int> > B;
vector<int> C;
int n, k, m, q;
long double anal() {
  long double res = 0;
  for (int i = 0; i < m; ++i) {
    res += (long double)A[B.back()[i] - 1];
    used[B.back()[i] - 1] = 1;
  }
  res /= (long double)m;
  return res;
}
int main() {
  long double _min = inf;
  long double _max = -1;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> A[i];
  m = n / k;
  Q.reserve(m);
  cin >> q;
  for (int i = 0; i < q; ++i) {
    Q.clear();
    for (int j = 0; j < m; ++j) {
      int x;
      cin >> x;
      Q.push_back(x);
    }
    sort((Q).begin(), (Q).end());
    bool _new = 1;
    for (int j = 0; j < B.size(); ++j) {
      if (B[j][0] == Q[0]) {
        _new = 0;
        break;
      }
    }
    if (_new) {
      B.push_back(Q);
      long double _res = anal();
      if (_min > _res) _min = _res;
      if (_max < _res) _max = _res;
    }
  }
  if ((int)(B).size() < k) {
    C.reserve(n);
    for (int i = 0; i < n; ++i) {
      if (!used[i]) C.push_back(A[i]);
    }
    sort((C).begin(), (C).end());
    long double res = 0;
    for (int i = 0; i < m; ++i) {
      res += (long double)C[i];
    }
    res /= (long double)m;
    if (_min > res) _min = res;
    if (_max < res) _max = res;
    res = 0;
    for (int i = (int)(C).size() - 1; i >= (int)(C).size() - m; --i) {
      res += (long double)C[i];
    }
    res /= (long double)m;
    if (_min > res) _min = res;
    if (_max < res) _max = res;
  }
  cout.setf(ios::fixed);
  cout.precision(8);
  cout << _min << " " << _max << "\n";
  return 0;
}
