#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> p;
  vector<int> ans;
  int n, k, x, f, used[1000], z[1000], m, i, j, t, q;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; ++i) {
    scanf("%d", &z[i]);
  }
  scanf("%d", &m);
  t = n / k;
  for (i = 0; i < n; ++i) {
    used[i] = 0;
  }
  for (i = 0; i < m; ++i) {
    f = 0;
    q = 0;
    for (j = 0; j < t; ++j) {
      scanf("%d", &x);
      f += used[x - 1];
      used[x - 1] = 1;
      q += z[x - 1];
    }
    if (!f) {
      --k;
      ans.push_back(q);
    }
  }
  if (k) {
    for (i = 0; i < n; ++i) {
      if (!used[i]) {
        p.push_back(z[i]);
      }
    }
    sort(p.begin(), p.end());
    x = 0;
    for (i = 0; i < t; ++i) {
      x += p[i];
    }
    ans.push_back(x);
    x = 0;
    for (i = (int)(p.size()) - 1; i >= (int)(p.size()) - t; --i) {
      x += p[i];
    }
    ans.push_back(x);
  }
  sort(ans.begin(), ans.end());
  printf("%.10lf %.10lf", double(ans[0]) / t, (double)(ans.back()) / t);
  return 0;
}
