#include <bits/stdc++.h>
using namespace std;
const int INF = 2000000000;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
template <typename T>
T sqr(const T &x) {
  return x * x;
}
template <typename T>
string GetString(const T &x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
int n, k, q;
int sz = 0;
vector<int> a;
deque<bool> mask;
double GetLevel(const basic_string<int> &x) {
  double sum = 0;
  for (int(i) = 0; (i) < (x.size()); ++(i)) {
    sum += a[x[i]];
  }
  return sum / (0.0 + x.size());
}
int main() {
  cin >> n >> k;
  sz = n / k;
  a.resize(n);
  mask.resize(n, true);
  for (int(i) = 0; (i) < (n); ++(i)) {
    cin >> a[i];
  }
  cin >> q;
  double minRes = 1e18;
  double maxRes = 0;
  set<basic_string<int> > cnt;
  for (int(i) = 0; (i) < (q); ++(i)) {
    basic_string<int> tmp;
    for (int(j) = 0; (j) < (sz); ++(j)) {
      int val;
      cin >> val;
      tmp += --val;
      mask[val] = false;
    }
    sort((tmp).begin(), (tmp).end());
    cnt.insert(tmp);
    double sum = GetLevel(tmp);
    minRes = min(minRes, sum);
    maxRes = max(maxRes, sum);
  }
  vector<int> b;
  for (int(i) = 0; (i) < (n); ++(i)) {
    if (mask[i]) b.push_back(a[i]);
  }
  sort((b).begin(), (b).end());
  if (b.size() < sz || cnt.size() == k) {
    printf("%.10f %.10f\n", minRes, maxRes);
    return 0;
  }
  double sum = 0;
  for (int i = 0; i < sz; ++i) {
    sum += b[i];
  }
  sum /= (n / k + 0.0);
  minRes = min(minRes, sum);
  maxRes = max(maxRes, sum);
  sum = 0;
  for (int i = 0, j = (int)b.size() - 1; i < sz; ++i, --j) {
    sum += b[j];
  }
  sum /= (sz + 0.0);
  minRes = min(minRes, sum);
  maxRes = max(maxRes, sum);
  printf("%.10f %.10f\n", minRes, maxRes);
  return 0;
}
