#include <bits/stdc++.h>
using namespace std;
int flag[105];
double val[105];
vector<double> rest;
int main() {
  ios_base::sync_with_stdio(false);
  int n, q, t;
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> val[i];
  t = n / q;
  double mn = 200, mx = 0.0;
  int qu;
  cin >> qu;
  while (qu--) {
    int x;
    double sum = 0, tot = t;
    for (int i = 0; i < t; i++) {
      cin >> x;
      x--;
      flag[x] = 1;
      sum += val[x];
    }
    sum /= tot;
    mn = min(mn, sum);
    mx = max(mx, sum);
  }
  for (int i = 0; i < n; i++)
    if (!flag[i]) rest.push_back(val[i]);
  if (rest.size() <= (n - q * (n / q)))
    ;
  else {
    sort(rest.begin(), rest.end());
    double sum = 0, tot = t;
    for (int i = 0; i < t; i++) sum += rest[i];
    sum /= tot;
    mn = min(mn, sum);
    sum = 0;
    for (int i = rest.size() - t; i < rest.size(); i++) sum += rest[i];
    sum /= tot;
    mx = max(mx, sum);
  }
  cout << fixed << setprecision(12) << mn << " " << mx << endl;
  return 0;
}
