#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
const int INFINITE = 0x3f3f3f3f;
template <class T>
inline void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline T lowbit(T n) {
  return (n ^ (n - 1)) & n;
}
template <class T>
inline int countbit(T n) {
  return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));
}
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<string> VS;
VI a;
set<VI> known;
set<VI>::iterator it;
vector<bool> used;
double calc(VI n) {
  double res = 0.0;
  int len = n.size();
  for (int i = (int)(0); i < (int)(len); i++) {
    res += a[n[i] - 1];
    used[n[i] - 1] = true;
  }
  res /= len;
  return res;
}
int main() {
  int n, k;
  cin >> n >> k;
  used.resize(n);
  double maxm = -1.0 * INFINITE, minm = 1.0 * INFINITE;
  int l = (int)floor(1.0 * n / k);
  for (int i = (int)(0); i < (int)(n); i++) {
    int t;
    cin >> t;
    a.push_back(t);
  }
  int q;
  cin >> q;
  for (int i = (int)(0); i < (int)(q); i++) {
    VI nums(l);
    for (int j = (int)(0); j < (int)(l); j++) cin >> nums[j];
    sort((nums).begin(), (nums).end());
    known.insert(nums);
  }
  for (it = known.begin(); it != known.end(); it++) {
    double res = calc(*it);
    checkmin(minm, res);
    checkmax(maxm, res);
  }
  if (known.size() == k) {
    printf("%.10lf %.10lf\n", minm, maxm);
    return 0;
  }
  VI left;
  for (int i = (int)(0); i < (int)(n); i++) {
    if (used[i]) continue;
    left.push_back(a[i]);
  }
  sort((left).begin(), (left).end());
  double resMin = 0.0;
  int lenLeft = (int)left.size();
  for (int i = 0; i < min(l, lenLeft); i++) resMin += left[i];
  resMin /= min(l, lenLeft);
  checkmin(minm, resMin);
  reverse((left).begin(), (left).end());
  double resMax = 0.0;
  for (int i = 0; i < min(l, lenLeft); ++i) resMax += left[i];
  resMax /= min(l, lenLeft);
  checkmax(maxm, resMax);
  printf("%.10lf %.10lf\n", minm, maxm);
  return 0;
}
