#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e2 + 5;
int a[MAX];
bool dead[MAX];
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int d = n / k;
  for (int i = int(1); i < int(n + 1); i++) {
    cin >> a[i];
  }
  set<int> out;
  for (int i = int(1); i < int(n + 1); i++) {
    out.insert(i);
  }
  int rest = n;
  int q;
  cin >> q;
  double minn = 1e18, maxx = -1e18;
  set<set<int> > cards;
  for (int i = int(0); i < int(q); i++) {
    double avg = 0;
    set<int> s;
    for (int j = int(0); j < int(d); j++) {
      int cur;
      cin >> cur;
      s.insert(cur);
      avg += a[cur];
      if (!dead[cur]) {
        dead[cur] = true;
        rest--;
      }
    }
    cards.insert(s);
    avg /= d;
    minn = min(minn, avg);
    maxx = max(maxx, avg);
  }
  if ((int)cards.size() < k && rest >= d) {
    vector<int> v;
    for (int i = int(1); i < int(n + 1); i++) {
      if (!dead[i]) {
        v.push_back(a[i]);
      }
    }
    sort(v.begin(), v.end());
    double avg = 0.0;
    for (int i = int(0); i < int(d); i++) {
      avg += v[i];
    }
    avg /= d;
    minn = min(minn, avg);
    avg = 0.0;
    for (int i = int(v.size() - 1); i >= int(v.size() - d); i--) {
      avg += v[i];
    }
    avg /= d;
    maxx = max(maxx, avg);
  }
  cout << fixed << setprecision(15) << minn << " " << maxx << '\n';
  return 0;
}
