#include <bits/stdc++.h>
using namespace std;
struct Ticket {
  vector<int> teorem;
};
const int size = 101;
int teorem_cost[size];
vector<Ticket> tickets;
vector<pair<int, int> > ticket_propability;
set<int> unuse_teorem;
int B();
Ticket get_ticket(int min_ticket_size);
double get_ticket_value(const Ticket& ticket);
void out_tickets() {
  for (int i = 0; i < tickets.size(); ++i) {
    for (int j = 0; j < tickets[i].teorem.size(); ++j) {
      cout << tickets[i].teorem[j] << " ";
    }
    cout << endl;
  }
}
int B() {
  int n = 0, k = 0, q = 0;
  cin >> n >> k;
  int min_ticket_size = n / k;
  for (int i = 0; i < n; ++i) {
    int x = 0;
    cin >> x;
    ticket_propability.push_back(make_pair(x, i + 1));
    teorem_cost[i + 1] = x;
  }
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int x = 0;
    Ticket ticket;
    for (int j = 0; j < min_ticket_size; ++j) {
      cin >> x;
      if (!unuse_teorem.count(x)) {
        ticket.teorem.push_back(x);
      }
      unuse_teorem.insert(x);
    }
    if (ticket.teorem.size() == min_ticket_size) {
      tickets.push_back(ticket);
    }
  }
  if (tickets.size() != k) {
    sort(ticket_propability.begin(), ticket_propability.end());
    Ticket swap_ticket = get_ticket(min_ticket_size);
    if (swap_ticket.teorem.size() == min_ticket_size) {
      tickets.push_back(get_ticket(min_ticket_size));
    }
    reverse(ticket_propability.begin(), ticket_propability.end());
    swap_ticket = get_ticket(min_ticket_size);
    if (swap_ticket.teorem.size() == min_ticket_size) {
      tickets.push_back(get_ticket(min_ticket_size));
    }
  }
  double min = 2 << 10;
  double max = 0.0;
  for (int i = 0; i < tickets.size(); ++i) {
    double value = get_ticket_value(tickets[i]);
    min = std::min(min, value);
    max = std::max(max, value);
  }
  printf("%.10f %.10f\n", min, max);
  return 0;
}
Ticket get_ticket(int min_ticket_size) {
  vector<int> swap_teorems;
  for (int i = 0; i < ticket_propability.size(); ++i) {
    int index = ticket_propability[i].second;
    if (!unuse_teorem.count(index)) {
      swap_teorems.push_back(index);
    }
    if (min_ticket_size == swap_teorems.size()) {
      break;
    }
  }
  Ticket ticket;
  ticket.teorem = swap_teorems;
  return ticket;
}
double get_ticket_value(const Ticket& ticket) {
  double value = 0;
  for (int i = 0; i < ticket.teorem.size(); ++i) {
    value += teorem_cost[ticket.teorem[i]];
  }
  value /= (double)ticket.teorem.size();
  return value;
}
int main() {
  B();
  return 0;
}
