#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  while (x > 0 && y > 0) {
    if (x > y) {
      x %= y;
    } else {
      y %= x;
    }
  }
  return x + y;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  vector<bool> used(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int q;
  cin >> q;
  int tasks = n / k;
  int best = -1, worse = 1 << 30;
  int ticketsLeft = k;
  for (int i = 1; i <= q; i++) {
    int curSum = 0;
    for (int j = 1; j <= tasks; j++) {
      int num;
      cin >> num;
      if (!used[num] && j == 1) {
        ticketsLeft--;
      }
      used[num] = true;
      curSum += a[num];
    }
    best = max(best, curSum);
    worse = min(worse, curSum);
  }
  vector<int> unUsed;
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      unUsed.push_back(a[i]);
    }
  }
  if (unUsed.size() >= tasks && ticketsLeft > 0) {
    sort(unUsed.begin(), unUsed.end());
    int curSum = 0;
    for (int i = 0; i < tasks; i++) {
      curSum += unUsed[i];
    }
    best = max(best, curSum);
    worse = min(worse, curSum);
    reverse(unUsed.begin(), unUsed.end());
    curSum = 0;
    for (int i = 0; i < tasks; i++) {
      curSum += unUsed[i];
    }
    best = max(best, curSum);
    worse = min(worse, curSum);
  }
  printf("%.15lf %.15lf\n", double(worse) / double(tasks),
         double(best) / double(tasks));
}
