#include <bits/stdc++.h>
template <typename T>
inline void SWAP(T &a, T &b) {
  T tmp = a;
  a = b;
  b = tmp;
}
template <typename T>
inline T ABS(const T &val) {
  return val < 0 ? -val : val;
}
template <typename T>
inline T MAX(const T &a, const T &b) {
  return a > b ? a : b;
}
template <typename T>
inline T MIN(const T &a, const T &b) {
  return a < b ? a : b;
}
template <typename T>
inline T SQR(const T &a) {
  return a * a;
}
const int INTinf = 2147483647;
const int nINTinf = 0 - 2147483648;
const long long LLinf = 9223372036854775807LL;
using namespace std;
int n, m;
int a[105];
bool used[105];
int k;
int q, w;
int nom;
struct sss {
  vector<int> mass;
  sss() {}
  void add(int nom) { mass.push_back(nom); }
  void S() { sort(mass.begin(), mass.end()); }
  bool operator<(const sss &q) const {
    for (int i = 0; i != mass.size(); i++) {
      if (mass[i] != q.mass[i]) {
        return mass[i] < q.mass[i];
      }
    }
    return false;
  }
};
set<sss> ST;
int main() {
  cin >> n >> m;
  nom = n / m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  cin >> k;
  double MN = INTinf;
  double MX = nINTinf;
  for (int i = 0; i != k; i++) {
    sss vl;
    long long _SUMM = 0L;
    for (int j = 0; j != nom; j++) {
      cin >> q;
      used[q] = true;
      _SUMM += a[q];
      vl.add(q);
    }
    double val2 = ((double)_SUMM) / nom;
    if (MN > val2) {
      MN = val2;
    }
    if (MX < val2) {
      MX = val2;
    }
    vl.S();
    ST.insert(vl);
  }
  if (ST.size() < m) {
    vector<int> vl;
    for (int i = 1; i <= n; i++) {
      if (!used[i]) vl.push_back(a[i]);
    }
    sort(vl.begin(), vl.end());
    long long _SUMM = 0L;
    for (int i = 0; i != nom; i++) {
      _SUMM += vl[i];
    }
    double val2 = ((double)_SUMM) / nom;
    if (MN > val2) {
      MN = val2;
    }
    if (MX < val2) {
      MX = val2;
    }
    _SUMM = 0L;
    int pp = 0;
    for (int i = vl.size() - 1; pp != nom; i--, pp++) {
      _SUMM += vl[i];
    }
    val2 = ((double)_SUMM) / nom;
    if (MN > val2) {
      MN = val2;
    }
    if (MX < val2) {
      MX = val2;
    }
  }
  cout.setf(ios_base::fixed);
  cout.precision(9);
  cout << MN << ' ' << MX << endl;
  return 0;
}
