#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-10;
template <typename T, typename S>
vector<T>& operator<<(vector<T>& a, S b) {
  a.push_back(b);
  return a;
}
template <typename T>
void operator>>(vector<T>& a, int b) {
  while (b--)
    if (!a.empty()) a.pop_back();
}
bool isprime(int n) {
  if (n < 2) return false;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
long long b_pow(long long x, long long n) {
  return n ? b_pow(x * x, n / 2) * (n % 2 ? x : 1) : 1ll;
}
string itos(int n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
long long in() {
  long long n;
  scanf("%lld", &n);
  return n;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> used(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int t;
  cin >> t;
  double mi = 1e9, mx = -1e9;
  for (int i = 0; i < t; i++) {
    double sum = 0;
    for (int j = 0; j < n / k; j++) {
      int x;
      cin >> x;
      x--;
      used[x] = true;
      sum += a[x];
    }
    sum /= n / k;
    mi = min(mi, sum);
    mx = max(mx, sum);
  }
  vector<int> b;
  for (int i = 0; i < n; i++) {
    if (used[i] == 0) b.push_back(a[i]);
  }
  int uc = (n - b.size()) / (n / k);
  if (b.size() >= n / k && uc < k) {
    sort(b.begin(), b.end());
    double sum1 = 0, sum2 = 0;
    for (int i = 0; i < n / k; i++) {
      sum1 += b[i];
      sum2 += b[b.size() - 1 - i];
    }
    sum1 /= n / k;
    sum2 /= n / k;
    mi = min(mi, sum1);
    mx = max(mx, sum1);
    mi = min(mi, sum2);
    mx = max(mx, sum2);
  }
  printf("%.10lf %.10lf\n", mi, mx);
}
