#include <bits/stdc++.h>
using namespace std;
const double INF = 1000000000.0;
double a[105], b[105];
bool use[105];
int main() {
  int n, k, all = 0, size;
  double maxi = -INF, mini = INF;
  cin >> n >> k;
  size = n / k;
  for (int i = 0; i < n; i++) cin >> a[i];
  int q, x, t = 0;
  cin >> q;
  for (int i = 0; i < q; i++) {
    double sum = 0.0;
    bool was = true;
    for (int j = 0; j < size; j++) {
      cin >> x;
      --x;
      was &= use[x];
      use[x] = true;
      sum += a[x];
    }
    all += !was;
    mini = min(mini, sum / size);
    maxi = max(maxi, sum / size);
  }
  for (int i = 0; i < n; i++)
    if (!use[i]) b[t++] = a[i];
  sort(b, b + t);
  if (t >= size && all != k) {
    double sum = 0.0;
    for (int i = 0; i < size; i++) sum += b[i];
    mini = min(mini, sum / size);
    sum = 0.0;
    for (int i = t - 1; i >= t - size; i--) sum += b[i];
    maxi = max(maxi, sum / size);
  }
  printf("%.7f %.7f", mini, maxi);
  return 0;
}
