#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 5;
int num[N];
vector<double> ans;
vector<int> temp;
bool visit[N];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &num[i]);
  int q;
  scanf("%d", &q);
  int m = n / k;
  int totall = 0;
  for (int i = 1; i <= q; i++) {
    int sum = 0;
    for (int j = 1; j <= m; j++) {
      int x;
      scanf("%d", &x);
      sum += num[x];
      if (!visit[x]) {
        totall++;
        visit[x] = true;
      }
    }
    ans.push_back((double)sum / (double)m);
  }
  for (int i = 1; i <= n; i++) {
    if (visit[i]) continue;
    temp.push_back(num[i]);
  }
  sort(temp.begin(), temp.end());
  if (temp.size() >= m && totall < k * m) {
    int sum = 0;
    for (int i = 0; i < m; i++) {
      sum += temp[i];
    }
    ans.push_back((double)sum / (double)m);
    sum = 0;
    for (int i = (int)temp.size() - 1; i >= (int)temp.size() - m; i--) {
      sum += temp[i];
    }
    ans.push_back((double)sum / (double)m);
  }
  sort(ans.begin(), ans.end());
  printf("%.10lf %.10lf\n", ans[0], ans[(int)ans.size() - 1]);
}
