#include <bits/stdc++.h>
using namespace std;
double k[101], kk[101];
int main() {
  cout.precision(10);
  int a, b, i, j, c, d, e;
  for (; cin >> a >> b;) {
    double mi = 100, ma = 0, mii = 100, maa = 0;
    set<int> l;
    for (i = 1; i <= a; cin >> k[i++])
      ;
    c = a / b;
    cin >> d;
    for (i = 1; i <= d; i++) {
      double x = 0;
      for (j = 1; j <= c; j++) {
        cin >> e;
        l.insert(e);
        x += k[e];
      }
      x /= c;
      if (x > ma) ma = x;
      if (x < mi) mi = x;
    }
    for (i = 1, j = 0; i <= a; i++) {
      if (l.find(i) == l.end()) {
        j++;
        kk[j] = k[i];
      }
    }
    sort(kk + 1, kk + j + 1);
    double y = 0, z = 0;
    if (j >= c && l.size() < (a / b) * b) {
      for (i = 1; i <= c; i++) {
        y += kk[i];
      }
      for (i = c; i > 0; i--) {
        z += kk[j - i + 1];
      }
      y /= c;
      z /= c;
      if (y < mii) mii = y;
      if (z > maa) maa = z;
    }
    cout << fixed << (mii < mi ? mii : mi) << ' ' << (maa > ma ? maa : ma)
         << endl;
  }
  return 0;
}
