#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int n, k, q, p;
int A[200], B[200];
double M, m;
vector<int> V;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> A[i];
  M = -1000000000;
  m = 1000000000;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int cur = 0;
    for (int j = 1; j <= n / k; j++) {
      cin >> p;
      B[p] = 1;
      cur += A[p];
    }
    M = max(M, 1.0 * cur / (n / k));
    m = min(m, 1.0 * cur / (n / k));
  }
  for (int i = 1; i <= n; i++)
    if (!B[i]) {
      V.push_back(A[i]);
    }
  sort(V.begin(), V.end());
  if (V.size() > n % k) {
    int cur = 0;
    for (int j = 0; j < n / k; j++) cur += V[j];
    m = min(m, 1.0 * cur / (n / k));
    M = max(M, 1.0 * cur / (n / k));
    cur = 0;
    for (int j = V.size() - n / k; j < V.size(); j++) cur += V[j];
    m = min(m, 1.0 * cur / (n / k));
    M = max(M, 1.0 * cur / (n / k));
  }
  cout.setf(ios::fixed);
  cout.precision(10);
  cout.setf(ios::showpoint);
  cout << m << " " << M << endl;
  return 0;
}
