#include <bits/stdc++.h>
using namespace std;
int n, m;
int ans, sum, tmp;
int MAX, MIN;
int a[110], del[110] = {0}, d[110], nd = 0;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  MIN = 999999, MAX = -999999;
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    sum = 0;
    for (int j = 0; j < n / m; j++) {
      int x;
      scanf("%d", &x);
      del[x - 1] = 1;
      sum += a[x - 1];
    }
    MIN = min(MIN, sum);
    MAX = max(MAX, sum);
  }
  for (int i = 0; i < n; i++)
    if (!del[i]) d[nd++] = a[i];
  sort(d, d + nd);
  if (n - nd < n / m * m) {
    sum = 0;
    for (int i = 0; i < n / m; i++) sum += d[i];
    MIN = min(MIN, sum);
    sum = 0;
    for (int i = nd - 1; i >= nd - n / m; i--) sum += d[i];
    MAX = max(MAX, sum);
  }
  printf("%lf %lf", ((double)(MIN)) / ((double)(n / m)),
         ((double)(MAX)) / ((double)(n / m)));
}
