#include <bits/stdc++.h>   using namespace std;   const int INF = 2147483647;   const double PI = 3.141592653589793;   int n, k, l, a[105], used[105], suma, i, j, q, b;   double maxx, minn;   vector<int> wek;   int main() {     scanf( %d %d , &n, &k);     l = n / k;     for (i = 0; i < n; i++) {       scanf( %d , &a[i]);       used[i] = 0;     }     maxx = -INF;     minn = INF;     scanf( %d , &q);     for (j = 0; j < q; j++) {       suma = 0;       for (i = 0; i < l; i++) {         scanf( %d , &b);         b--;         suma += a[b];         used[b] = 1;       }       maxx = max(maxx, suma * 1.0 / l);       minn = min(minn, suma * 1.0 / l);     }     wek.resize(0);     for (i = 0; i < n; i++)       if (!used[i]) wek.push_back(a[i]);     sort(wek.begin(), wek.end());     if (wek.size() == n - k * l) {       printf( %.8lf %.8lf n , minn, maxx);       return 0;     }     suma = 0;     for (i = 0; i < l; i++) suma += wek[i];     maxx = max(maxx, suma * 1.0 / l);     minn = min(minn, suma * 1.0 / l);     suma = 0;     for (i = wek.size() - 1; i >= (int)wek.size() - l; i--) suma += wek[i];     maxx = max(maxx, suma * 1.0 / l);     minn = min(minn, suma * 1.0 / l);     printf( %.8lf %.8lf n , minn, maxx);     return 0;   }   