Vasya is about to take his first university exam in about several minutes. And it's not just some ordinary exam, it's on mathematical analysis. Of course, right now Vasya can only think of one thing: what the result of his talk with the examiner will be...

To prepare for the exam, one has to study proofs of *n* theorems. It is known that there will be *k* examination cards on the exam and each card contains <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/ccab2ac008a075768cfcbe37d558a7f5643a7c71.png" style="max-width: 100.0%;max-height: 100.0%;"/> distinct theorems. Besides, no theorem is mentioned in more than one card (that is, <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/17aca828c99fbd32cc94da9ea04c5b4660f188d1.png" style="max-width: 100.0%;max-height: 100.0%;"/> theorems won't be mentioned in any card). During the exam several students may get the same card.

We do not know the exact way theorems are distributed by cards, however the students that took the exam before Vasya told him what theorems their cards contained. Vasya evaluates his level of proficiency in the *i*-th theorem by some number *a*<sub class="lower-index">*i*</sub>. The level of proficiency in some card is the average of the levels of proficiency in the theorems that are included in the card. Now Vasya wants to know the minimally and maximally possible levels of his proficiency in the card he gets on the exam. Vasya wants to determine it by the data he has collected from other students. Unfortunately, Vasya has no time left to do the math and he asked you to help him.
The first line contains two integers *n* and *k* (1 ≤ *k* ≤ *n* ≤ 100) — the number of theorems and the number of cards correspondingly. The second line contains *n* integers *a*<sub class="lower-index">*i*</sub> (0 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 100), the *i*-th number (1 ≤ *i* ≤ *n*) corresponds to Vasya's proficiency in the *i*-th theorem.

The third line contains number *q* (0 ≤ *q* ≤ 100) — the number of people that have taken the exam before Vasya. Each of the following *q* lines contains the description of a student's card: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/ccab2ac008a075768cfcbe37d558a7f5643a7c71.png" style="max-width: 100.0%;max-height: 100.0%;"/> integers from 1 to *n* inclusive. They are the numbers of theorems included in the card in the order in which they are enumerated in the input data. The numbers are given in an arbitrary order. It is guaranteed that the given cards are valid (that is, that all theorems in one card are different and that different people get cards that either don't contain the same theorems or coincide up to the theorems' permutation).
7 3
7 15 0 19 10 5 12
2
1 6
7 4
5.0000000000 15.5000000000
4 2
10 8 1 17
2
2 3
3 2
4.5000000000 13.5000000000
10 5
3 10 0 15 45 84 67 100 46 73
3
1 6
8 9
6 1
5.0000000000 73.0000000000
8 4
1 2 17 45 23 0 5 5
4
8 7
2 3
1 4
6 5
5.0000000000 23.0000000000
11 3
60 100 84 74 19 77 36 48 70 18 63
4
3 7 11
5 9 2
2 9 5
8 10 1
42.0000000000 63.0000000000
9 4
25 0 71 69 12 67 39 4 62
2
2 1
5 7
12.5000000000 70.0000000000
6 4
85 84 81 33 28 94
3
3
4
6
28.0000000000 94.0000000000
7 2
4 34 56 0 35 23 2
1
1 2 6
12.3333333333 31.0000000000
3 2
1 2 3
2
1
2
1.0000000000 2.0000000000
1 1
0
1
1
0.0000000000 0.0000000000
1 1
99
0
99.0000000000 99.0000000000
5 1
34 0 100 45 3
0
36.4000000000 36.4000000000
6 1
33 2 7 99 0 0
1
3 6 5 4 1 2
23.5000000000 23.5000000000
6 6
1 0 46 5 79 4
0
0.0000000000 79.0000000000
8 8
3 7 74 90 100 74 4 55
6
2
3
4
8
6
7
3.0000000000 100.0000000000
10 5
0 0 0 0 0 0 0 0 0 0
3
1 2
8 5
2 1
0.0000000000 0.0000000000
15 4
3 6 15 0 99 100 57 32 67 99 44 10 85 45 37
6
2 3 1
15 13 12
3 1 2
10 9 5
8 4 11
8 4 11
8.0000000000 88.3333333333
8 3
45 67 0 98 12 56 93 99
1
4 5
22.5000000000 96.0000000000
10 4
45 32 0 0 99 73 24 22 81 56
6
4 3
3 4
5 9
4 3
9 5
5 9
0.0000000000 90.0000000000
10 4
45 32 0 0 99 73 24 22 81 56
2
4 8
1 9
11.0000000000 86.0000000000
4 1
4 10 0 35
7
1 2 3 4
1 2 4 3
3 2 4 1
4 3 2 1
3 1 4 2
2 4 1 3
4 3 1 2
12.2500000000 12.2500000000
12 3
4 77 0 90 2 5 74 7 77 100 45 34
3
9 12 1 5
4 3 10 2
11 6 7 8
29.2500000000 66.7500000000
15 2
56 9 100 86 5 44 3 63 98 23 11 84 56 33 84
1
4 7 6 2 8 3 15
38.2857142857 55.5714285714
19 2
63 18 76 3 18 22 2 49 50 23 13 76 29 36 95 49 78 95 25
5
15 5 3 4 18 17 6 1 8
14 11 2 19 13 7 12 16 9
19 16 13 9 2 11 14 12 7
12 9 11 7 14 2 19 13 16
15 18 17 3 1 5 8 6 4
33.1111111111 55.4444444444
67 5
11 89 2 71 41 6 35 19 34 51 49 97 37 57 84 39 3 62 14 1 67 18 49 77 16 46 99 38 3 51 68 72 31 79 35 10 65 90 28 43 88 67 2 13 93 40 52 28 75 26 90 3 22 29 44 38 73 62 17 92 91 37 29 87 25 54 8
3
46 57 28 2 54 12 19 18 42 4 14 37 13
61 11 30 64 38 47 15 41 67 29 20 35 45
11 35 67 15 38 47 61 45 30 20 41 64 29
10.9230769231 71.9230769231
89 3
100 52 96 60 96 86 70 2 16 44 79 37 18 16 92 0 55 49 98 83 47 42 45 92 33 99 20 52 32 47 30 61 89 86 29 64 80 96 35 85 17 39 14 2 43 8 65 98 62 57 54 73 87 79 34 42 50 89 56 54 52 59 93 31 95 86 29 4 4 46 2 14 45 73 42 24 3 55 47 10 60 61 67 16 20 71 47 91 29
1
38 1 80 16 77 58 17 30 39 4 49 63 11 47 8 61 10 24 64 15 74 6 45 12 35 79 22 52 20
25.3448275862 74.4137931034
53 27
100 85 0 86 19 32 82 66 54 10 9 81 40 65 23 17 58 68 100 46 28 48 28 11 79 11 36 89 61 11 67 88 79 28 16 93 31 34 54 9 33 45 60 18 23 28 38 71 76 51 10 9 92
20
43
43
14
2
25
31
25
13
48
1
38
46
9
19
30
1
28
19
43
27
0.0000000000 100.0000000000
93 3
47 45 32 90 54 22 99 70 55 22 2 86 23 18 0 42 42 41 63 90 60 70 81 38 42 4 17 96 15 65 2 21 66 5 18 20 97 38 18 2 60 41 38 18 39 38 43 75 51 97 72 90 59 4 40 34 40 18 15 71 82 9 66 82 0 50 21 37 47 31 65 42 6 78 94 0 5 56 85 28 37 30 77 11 71 42 48 4 42 13 96 82 35
2
62 86 47 34 31 59 58 76 15 88 23 19 87 48 41 32 74 89 26 20 61 5 35 39 81 2 17 55 40 69 38
9 3 53 73 18 92 52 12 46 82 75 27 68 24 7 79 22 50 67 65 33 51 54 10 8 70 57 43 25 63 30
36.2258064516 51.3870967742
99 1
20 83 45 17 53 33 56 58 65 26 68 44 21 52 55 21 79 23 82 11 19 33 29 66 10 29 69 15 5 0 99 25 13 83 62 63 1 22 7 93 51 41 64 35 89 10 97 0 43 34 89 97 52 65 80 0 73 12 100 45 78 8 5 47 23 91 46 33 70 37 25 55 75 60 100 30 28 87 59 1 58 39 29 66 60 66 68 77 0 93 18 28 51 64 36 25 63 74 6
0
46.5757575758 46.5757575758
100 54
46 64 22 47 5 70 61 8 25 78 88 62 91 52 3 55 46 63 90 27 92 64 33 83 7 7 0 47 64 85 89 3 40 49 11 14 51 93 5 56 8 37 82 49 10 7 14 7 33 66 35 66 41 23 7 56 55 2 74 39 75 16 46 63 81 10 73 67 70 30 37 22 97 33 52 60 38 42 16 43 79 70 15 51 70 8 99 75 7 76 49 10 96 74 82 97 15 98 75 11
20
91
60
90
92
88
52
53
15
92
58
88
18
95
8
43
22
69
48
42
88
0.0000000000 99.0000000000
86 5
51 59 52 84 64 40 9 6 35 63 66 82 52 52 84 66 89 85 30 0 91 81 73 0 58 22 59 96 27 28 35 2 79 55 88 43 92 97 89 52 49 27 100 54 4 11 28 38 86 82 63 72 31 75 77 42 35 1 56 11 93 56 80 63 5 78 63 73 8 2 44 18 6 20 47 4 88 16 24 13 100 68 34 21 0 70
4
57 32 69 9 61 39 10 6 56 36 78 8 80 58 50 65 77
2 83 3 31 85 21 62 28 79 46 49 20 22 34 42 12 76
32 65 58 39 57 9 50 8 61 10 80 77 69 36 56 78 6
4 86 40 30 54 75 37 48 64 15 59 44 16 5 43 73 81
24.6470588235 74.5882352941
90 15
78 78 57 46 96 3 2 79 26 58 95 79 33 33 54 60 26 93 85 74 51 100 68 40 51 14 78 0 73 61 17 59 8 40 87 93 57 72 38 92 20 15 77 74 97 59 33 45 69 71 71 32 25 58 86 26 13 36 6 73 56 36 30 43 38 26 58 6 74 13 11 23 80 54 81 76 41 22 1 73 10 15 82 47 66 50 98 74 12 63
9
88 89 86 66 12 15
59 3 38 78 53 18
21 61 36 39 57 4
67 55 14 46 60 54
84 75 9 23 48 1
57 4 61 21 36 39
79 72 2 83 6 26
4 61 36 39 21 57
74 32 24 11 85 42
6.1666666667 95.0000000000
100 87
89 43 79 20 88 74 41 99 16 64 53 54 54 59 26 20 31 81 100 66 12 71 93 40 53 2 55 69 53 91 23 54 43 19 78 73 95 70 69 47 15 63 60 88 98 63 13 66 95 55 12 3 4 12 14 79 80 15 62 15 93 11 23 86 17 71 22 21 40 90 71 90 81 40 50 68 55 28 100 12 0 21 66 93 80 91 62 37 9 7 59 10 18 73 7 32 50 12 57 87
50
25
54
83
46
6
39
48
85
10
79
66
97
6
85
64
67
87
44
65
67
41
5
3
76
93
49
26
82
3
11
47
13
70
74
82
99
43
91
42
7
92
80
78
45
3
84
6
29
38
45
0.0000000000 100.0000000000
82 2
89 81 1 65 17 37 65 73 19 20 67 15 86 99 30 70 44 83 2 50 20 93 57 64 30 85 53 9 22 18 97 13 85 38 70 96 3 85 12 72 44 10 62 93 60 81 7 91 17 13 64 63 83 96 15 9 62 43 83 72 65 89 49 75 36 61 98 89 48 45 74 80 37 39 71 1 76 69 56 72 28 86
1
41 71 27 69 17 14 20 46 53 64 5 35 7 9 56 18 75 36 16 34 81 37 58 65 66 4 40 8 44 19 31 38 30 60 77 80 42 63 73 33 43
51.6829268293 56.7804878049
10 6
100 100 100 100 100 100 100 100 100 100
6
4
10
2
4
7
5
100.0000000000 100.0000000000
100 6
14 6 0 34 22 84 9 18 94 61 16 83 79 58 80 22 16 78 51 74 5 96 29 75 91 89 78 85 12 25 24 65 23 66 54 56 89 25 18 51 74 83 89 31 6 45 79 17 35 16 74 93 82 80 62 6 46 14 90 68 51 59 1 27 73 95 89 17 43 63 23 26 99 77 23 39 43 100 65 80 78 71 48 48 31 3 69 7 26 2 44 57 99 68 1 18 9 62 97 43
0
6.9375000000 92.4375000000
67 5
11 89 2 71 41 6 35 19 34 51 49 97 37 57 84 39 3 62 14 1 67 18 49 77 16 46 99 38 3 51 68 72 31 79 35 10 65 90 28 43 88 67 2 13 93 40 52 28 75 26 90 3 22 29 44 38 73 62 17 92 91 37 29 87 25 54 8
3
46 57 28 2 54 12 19 18 42 4 14 37 13
61 11 30 64 38 47 15 41 67 29 20 35 45
11 35 67 15 38 47 61 45 30 20 41 64 29
10.9230769231 71.9230769231
23 5
30 38 57 63 1 26 11 47 47 95 83 9 61 24 82 82 86 99 90 18 4 5 76
5
2 15 21 13
1 4 9 7
3 8 14 17
23 6 5 11
12 10 22 16
37.7500000000 53.5000000000
100 3
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89
0
0.0000000000 2.6969696970
100 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100
0
1.0000000000 1.0000000000
100 100
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 100 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 67
0.9900000000 0.9900000000
100 100
1 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100
2
1
100
1.0000000000 100.0000000000
3 2
1 2 3
2
1
1
1.0000000000 3.0000000000
3 2
1 2 3
4
1
1
2
2
1.0000000000 2.0000000000
3 2
1 2 3
5
2
2
2
2
2
1.0000000000 3.0000000000
n, k = map(int, input().split())
ar = list(map(int, input().split()))
st = set()
ar2 = []
q = int(input())
for i in range(q):
    s = -1
    tmp = list(map(int, input().split()))
    for x in tmp:
        if (x - 1) in st:
            break
        if s == -1:
            s = 0
        st.add(x - 1)
        s += ar[x - 1]
    if s != -1:
        ar2.append(s)
st2 = (set(range(n)) ^ st)
mn = 10**15
mx = -1
if len(st2) >= n // k:
    ar5 = []
    for x in st2:
        ar5.append(ar[x])
    ar3 = sorted(ar5)
    ar4 = sorted(ar5, reverse=True)
    s1 = 0
    s2 = 0
    for i in range(n // k):
        s1 += ar3[i]
    for i in range(n // k):
        s2 += ar4[i]
    mn = min(mn, s1 / (n // k))
    mx = max(mx, s2 / (n // k))
for x in ar2:
    mn = min(mn, x / (n // k))
    mx = max(mx, x / (n // k))
print(mn, mx)
