#include <bits/stdc++.h>
using namespace std;
void ASS(bool b) {
  if (!b) {
    ++*(int*)0;
  }
}
#pragma comment(linker, "/STACK:106777216")
int gcd(int a, int b) {
  while (a) {
    int c = b % a;
    b = a;
    a = c;
  }
  return b;
}
int main() {
  int n, k;
  cin >> n >> k;
  int c = n / k;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  int q;
  cin >> q;
  int m0 = 1 << 30;
  int m1 = 0;
  vector<int> f(n, 0);
  for (int i = 0; i < (int)(q); i++) {
    int sum = 0;
    for (int j = 0; j < (int)(c); j++) {
      int x;
      cin >> x;
      x--;
      sum += a[x];
      f[x] = 1;
    }
    m0 = min(m0, sum);
    m1 = max(m1, sum);
  }
  vector<int> v;
  for (int i = 0; i < (int)(n); i++)
    if (!f[i]) v.push_back(a[i]);
  if (v.size() + k * c != n) {
    sort(v.begin(), v.end());
    int sum = 0;
    for (int i = 0; i < (int)(c); i++) sum += v[i];
    m0 = min(m0, sum);
    m1 = max(m1, sum);
    reverse(v.begin(), v.end());
    sum = 0;
    for (int i = 0; i < (int)(c); i++) sum += v[i];
    m0 = min(m0, sum);
    m1 = max(m1, sum);
  }
  printf("%0.10lf %0.10lf\n", m0 / (double)c, m1 / (double)c);
  return 0;
}
