#include <bits/stdc++.h>   using namespace std;   int a[111];   int id[111][111];   int vis[111];   int main() {     int n, m, k, q;     while (cin >> n >> k) {       m = n / k;       for (int i = 0; i < n; i++) {         cin >> a[i];         vis[i] = 0;       }       scanf( %d , &q);       double minv = 1 << 30, maxv = -1 << 30;       for (int i = 0; i < q; i++) {         int sum = 0;         for (int j = 0; j < m; j++) {           cin >> id[i][j];           vis[id[i][j] - 1] = 1;           sum += a[id[i][j] - 1];         }         if (double(sum) / m < minv) {           minv = double(sum) / m;         }         if (double(sum) / m > maxv) {           maxv = double(sum) / m;         }       }       vector<int> v;       for (int i = 0; i < n; i++) {         if (!vis[i]) {           v.push_back(a[i]);         }       }       sort(v.begin(), v.end());       if (v.size() >= m && (n - v.size()) < k * m) {         int sum = 0;         for (int i = 0; i < m; i++) {           sum += v[i];         }         if (double(sum) / m < minv) {           minv = double(sum) / m;         }         if (double(sum) / m > maxv) {           maxv = double(sum) / m;         }         reverse(v.begin(), v.end());         sum = 0;         for (int i = 0; i < m; i++) {           sum += v[i];         }         if (double(sum) / m < minv) {           minv = double(sum) / m;         }         if (double(sum) / m > maxv) {           maxv = double(sum) / m;         }       }       printf( %.9lf %.9lf n , minv, maxv);     }   }   