#include <bits/stdc++.h>
using namespace std;
void rint(int &r) { scanf("%d", &r); }
void rInt(long long &r) { scanf("%lld", &r); }
void ruint(unsigned int &r) { scanf("%u", &r); }
void ruInt(unsigned long long &r) { scanf("%llu", &r); }
int n, k, q;
int a[110];
set<int> st;
set<int> poi;
template <class T>
bool operator<(const vector<T> &v, const vector<T> &w) {
  if (v.size() != w.size()) return v.size() < w.size();
  for (int i = 0; i < (int)(v.size()); ++i) {
    if (v[i] != w[i]) return v[i] < w[i];
  }
  return false;
}
int main() {
  scanf("%d%d", &n, &k);
  int d = n / k;
  for (int i = 0; i < (int)(n); ++i) cin >> a[i], st.insert(i);
  set<vector<int> > sv;
  cin >> q;
  int q2 = 0;
  for (int i = 0; i < (int)(q); ++i) {
    vector<int> vi;
    int b;
    for (int j = 0; j < (int)(d); ++j) {
      cin >> b;
      b--;
      vi.push_back(b);
    }
    sort((vi).begin(), (vi).end());
    if (sv.find(vi) != sv.end()) continue;
    q2++;
    int s = 0;
    for (int j = 0; j < (int)(d); ++j) {
      int b = vi[j];
      s += a[b];
      st.erase(b);
    }
    poi.insert(s);
    sv.insert(vi);
  }
  int mini = 1000000000, maxi = -1;
  if (poi.size() > 0) {
    mini = min(mini, *(poi.begin())), maxi = max(maxi, *(poi.rbegin()));
  }
  vector<int> v;
  for (__typeof((st).begin()) it = (st).begin(); it != (st).end(); ++it) {
    v.push_back(a[*it]);
  }
  sort(v.begin(), v.end());
  if (q2 < k) {
    int m = 0, M = 0;
    for (int i = 0; i < (int)(d); ++i) {
      m += v[i];
      M += v[st.size() - 1 - i];
    }
    mini = min(mini, m);
    maxi = max(maxi, M);
  }
  printf("%.10f %.10f\n", (double)mini / d, (double)maxi / d);
  return 0;
}
