#include <bits/stdc++.h>
using namespace std;
bool vis[128] = {false};
vector<int> v[128];
int a[128];
int main() {
  int i, j, n, k, t;
  cin >> n >> k;
  t = n / k;
  for ((i) = 0; (i) < (n); (i)++) cin >> a[i];
  int num;
  cin >> num;
  for ((i) = 0; (i) < (num); (i)++) {
    for ((j) = 0; (j) < (t); (j)++) {
      int tmp;
      cin >> tmp;
      tmp--;
      vis[tmp] = true;
      v[i].push_back(a[tmp]);
    }
  }
  vector<int> vec;
  for ((i) = 0; (i) < (n); (i)++)
    if (!vis[i]) vec.push_back(a[i]);
  sort(vec.begin(), vec.end());
  int mx = 0, mn = 1000000;
  for ((i) = 0; (i) < (num); (i)++) {
    int sum = 0;
    for ((j) = 0; (j) < (t); (j)++) sum += v[i][j];
    mn = min(mn, sum);
    mx = max(mx, sum);
  }
  if (n - vec.size() < (n / k) * k) {
    int sum = 0;
    for ((i) = 0; (i) < (t); (i)++) sum += vec[i];
    mn = min(mn, sum);
    mx = max(mx, sum);
    int tm = 0;
    sum = 0;
    for (i = vec.size() - 1; tm < t; i--, tm++) sum += vec[i];
    mn = min(mn, sum);
    mx = max(mx, sum);
  }
  double eps = 1e-10;
  double minans = (double)mn / (double)t;
  double maxans = (double)mx / (double)t;
  printf("%.6lf %.6lf\n", minans + eps, maxans + eps);
  return 0;
}
