#include <bits/stdc++.h>
using namespace std;
const int MN = 1000 + 10;
vector<int> sp[MN], nused;
int arr[MN];
bool used[MN];
int main() {
  int n, k, q, len, cnt = 0;
  cin >> n >> k;
  len = n / k;
  for (int i = 0; i < n; i++) cin >> arr[i];
  cin >> q;
  double mn = 1e20, mx = -1e20;
  for (int i = 0; i < q; i++) {
    double sum = 0.0;
    for (int j = 0; j < len; j++) {
      int x;
      scanf("%d", &x);
      x--;
      if (!j && !used[x]) cnt++;
      sp[i].push_back(x);
      sum += arr[x];
      used[x] = true;
    }
    sum /= len;
    mn = min(sum, mn);
    mx = max(sum, mx);
  }
  for (int i = 0; i < n; i++)
    if (!used[i]) nused.push_back(arr[i]);
  sort(nused.begin(), nused.end());
  if (nused.size() >= len && k != cnt) {
    double sum1 = 0.0, sum2 = 0.0;
    for (int i = 0; i < len; i++) {
      sum1 += nused[i];
      sum2 += nused[(int)nused.size() - i - 1];
    }
    sum1 /= len;
    sum2 /= len;
    mn = min(sum1, mn);
    mx = max(sum1, mx);
    mn = min(sum2, mn);
    mx = max(sum2, mx);
  }
  printf("%0.10lf %0.10lf\n", mn, mx);
  return 0;
}
