#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1000;
const long long INF64 = 1e18 + 1000;
const int N = 6 * 100 * 1000 + 100;
const int MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  for (int i = int(1); i < int(n + 1); ++i) cin >> a[i];
  int q;
  cin >> q;
  vector<int> used(n + 1);
  int m = n / k;
  vector<int> r;
  int dif = 0;
  for (int i = 0; i < int(q); ++i) {
    double s = 0;
    int t;
    for (int j = 0; j < int(m); ++j) {
      cin >> t;
      used[t] = 1;
      s += a[t];
    }
    r.push_back(s);
  }
  for (int i = 1; i <= n; i++) {
    if (used[i]) dif++;
  }
  dif /= m;
  if (dif != k) {
    vector<int> nu;
    for (int i = int(1); i < int(n + 1); ++i) {
      if (!used[i]) nu.push_back(a[i]);
    }
    sort(nu.begin(), nu.end());
    double s = 0;
    n = nu.size();
    if (n >= m) {
      for (int i = 0; i < int(m); ++i) {
        s += nu[i];
      }
      r.push_back(s);
      s = 0;
      for (int i = int(n - m); i < int(n); ++i) {
        s += nu[i];
      }
      r.push_back(s);
    }
  }
  sort(r.begin(), r.end());
  printf("%.6f %.6f", 1.0 * r[0] / m, 1.0 * (*r.rbegin()) / m);
}
