#include <bits/stdc++.h>
using namespace std;
struct node {
  int ind;
  double a;
  int flag;
};
node nodes[1000];
int maxi(int a, int b) {
  if (a > b) return a;
  return b;
}
int mini(int a, int b) {
  if (a < b) return a;
  return b;
}
int n, m, k, q;
int ain[1000];
double a[1000];
bool comp(node a, node b) {
  if (a.flag == b.flag) return a.a < b.a;
  return a.flag < b.flag;
}
int main() {
  int i, j, l, kk;
  while (scanf("%d %d", &n, &k) == 2) {
    int tot;
    kk = k;
    for (i = 0; i < n; i++) {
      scanf("%d", &ain[i]);
      a[i] = ain[i];
      nodes[i].a = a[i];
      nodes[i].ind = i;
      nodes[i].flag = 0;
    }
    tot = n / k;
    scanf("%d", &q);
    double minans, maxans;
    double sumd;
    minans = 111000.0;
    maxans = -1.0;
    double ret, totd;
    totd = tot;
    int qq = 0;
    for (i = 1; i <= q; i++) {
      sumd = 0;
      bool found = 0;
      for (j = 1; j <= tot; j++) {
        scanf("%d", &k);
        k--;
        if (nodes[k].flag == 2) found = 1;
        nodes[k].flag = 2;
        sumd += nodes[k].a;
      }
      if (!found) qq++;
      ret = (sumd / totd);
      ret += .000000001;
      if (minans > ret) {
        minans = ret;
      }
      if (maxans < ret) {
        maxans = ret;
      }
    }
    if (kk == qq) {
      printf("%lf %lf\n", minans, maxans);
      continue;
    }
    sort(nodes, nodes + n, comp);
    k = 0;
    l = 0;
    for (i = 0; i < n; i++) {
      if (nodes[i].flag == 0) {
        k++;
        l++;
      }
      if (nodes[i].flag != 0) break;
    }
    if (k >= tot) {
      l = i - 1;
      sumd = 0;
      for (j = 1; j <= tot; j++) {
        sumd += nodes[l--].a;
      }
      ret = sumd / totd;
      ret += .00000001;
      if (maxans < ret) {
        maxans = ret;
      }
    }
    if (k >= tot) {
      sumd = 0;
      for (j = 0; j < tot; j++) {
        sumd += nodes[j].a;
      }
      ret = sumd / totd;
      ret += .000000001;
      if (minans > ret) {
        minans = ret;
      }
    }
    printf("%lf %lf\n", minans, maxans);
  }
  return 0;
}
