#include <bits/stdc++.h>
using namespace std;
const int N = 110;
const int M = 26;
const double pi = acos(-1.0);
const double eps = 1e-10;
int a[N], vis[N];
int main() {
  int n, k, m, T;
  scanf("%d %d", &n, &k);
  m = n / k;
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  scanf("%d", &T);
  int mn = 1e9 + 10, mx = 0;
  while (T--) {
    int sum = 0, t;
    for (int i = 0; i < m; i++) {
      scanf("%d", &t);
      vis[t] = 1;
      sum += a[t];
    }
    mn = min(mn, sum);
    mx = max(mx, sum);
  }
  int top = 0;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) a[top++] = a[i];
  if (top > n - m * k) {
    sort(a, a + top);
    int sum = 0;
    for (int i = 0; i < m; i++) sum += a[i];
    mn = min(mn, sum);
    sum = 0;
    for (int i = top - m; i < top; i++) sum += a[i];
    mx = max(mx, sum);
  }
  printf("%.6lf %.6lf\n", 1.0 * mn / m, 1.0 * mx / m);
  return 0;
}
