#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int a[105], c[105];
int g[102][102];
bool vis[105];
bool check(int num, int tol) {
  sort(c, c + num);
  for (int i = 0; i < tol; i++) {
    int j;
    for (j = 0; j < num; j++)
      if (g[i][j] != c[j]) break;
    if (j == num) return true;
  }
  return false;
}
void add(int num, int &tol) {
  for (int j = 0; j < num; j++) g[tol][j] = c[j];
  tol++;
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int q, num = n / k, tol = 0;
  double _min = 1e100, _max = 0;
  scanf("%d", &q);
  while (q--) {
    int sum = 0, idx;
    for (int i = 1; i <= num; i++) {
      scanf("%d", &idx);
      sum += a[idx];
      vis[idx] = true;
      c[i - 1] = idx;
    }
    double tmp = (double)sum / num;
    _min = min(_min, tmp);
    _max = max(_max, tmp);
    if (check(num, tol) == false) add(num, tol);
  }
  int l = 0;
  for (int i = 1; i <= n; i++)
    if (vis[i] == false) c[l++] = a[i];
  if (tol < k) {
    sort(c, c + l);
    int sum = 0;
    for (int i = 0; i < num; i++) sum += c[i];
    double tmp = (double)sum / num;
    _min = min(_min, tmp);
    sum = 0;
    for (int i = l - 1; i + num >= l; i--) sum += c[i];
    tmp = (double)sum / num;
    _max = max(_max, tmp);
  }
  printf("%.6lf %.6lf\n", _min, _max);
  return 0;
}
