The itertools module standardizes a core set of fast, memory efficient tools that are useful by themselves or in combination. Together, they form an iterator algebra making it possible to construct specialized tools succinctly and efficiently in pure Python. 

To read more about the functions in this module, check out their documentation here. 

You are given a list of $N$ lowercase English letters. For a given integer $\mbox{K}$, you can select any $\mbox{K}$ indices (assume $\mbox{I}$-based indexing) with a uniform probability from the list.  

Find the probability that at least one of the $\mbox{K}$ indices selected will contain the letter: '$\boldsymbol{\alpha}$'.  

Input Format

The input consists of three lines. The first line contains the integer $N$, denoting the length of the list. The next line consists of $N$ space-separated lowercase English letters, denoting the elements of the list. 

The third and the last line of input contains the integer $\mbox{K}$, denoting the number of
indices to be selected. 

Output Format

Output a single line consisting of the probability that at least one of the $\mbox{K}$ indices selected contains the letter:'$\boldsymbol{\alpha}$'. 

Note: The answer must be correct up to 3 decimal places. 

Constraints

$1\leq N\leq10$

$1\leq K\leq N$

All the letters in the list are lowercase English letters.

Sample Input

4 
a a c d
2

Sample Output

0.8333

Explanation

All possible unordered tuples of length $2$ comprising of indices from $\mbox{I}$ to $\begin{array}{c}A\end{array}$ are:

$(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)$ 

Out of these $\boldsymbol{6}$ combinations, $5$ of them contain either index $\mbox{I}$ or index $2$ which are the indices that contain the letter '$\boldsymbol{\alpha}$'. 

Hence, the answer is $\frac{5}{6}$.

Difficulty: MEDIUM

Solutions:
from math import factorial

def binomCoef(n, k):
	return factorial(n) / (factorial(k) * factorial(n - k))

def hypergeomPMF(k, N, K, n):
	A = binomCoef(K, k)
	B = binomCoef(N - K, n - k)
	C = binomCoef(N, n)
	return A * B / C
popSize = int(input())
S = str(input()).split()
draws = int(input())
num_of_As = S.count('a')
if num_of_As == 0:
	print('0.0000')
elif popSize == num_of_As:
	print('1.0000')
elif popSize == draws:
	print('1.0000')
else:
	print(round(1 - hypergeomPMF(0, popSize, num_of_As, draws), 4))


import itertools
input_max = input()
input_list = input().split()
input_size = int(input())
combinations = [e for e in itertools.combinations(input_list, input_size)]
count = 0
for e in combinations:
	if 'a' in e:
		count += 1
print(format(count / len(combinations), '.4f'))


from itertools import combinations
__author__ = 'namii'
N = 4
stringi = 'a a c d'
K = 2
(N, stringi, K) = (input(), input(), input())
L = list(stringi.split())
combs = combinations(L, int(K))
(count, matches) = (0, 0)
for combination in combs:
	count += 1
	if 'a' in combination:
		matches += 1
print('{:.4f}'.format(matches / count))


import string
symbols = string.ascii_lowercase
from itertools import combinations

def __starting_point():
	n = int(input().strip())
	arr = list(map(str, input().strip().split(' ')))
	times = int(input().strip())
	cmbts = list(combinations(sorted(arr), times))
	print('{:.4f}'.format(len(list([a for a in cmbts if a[0] == 'a'])) / len(cmbts)))
__starting_point()


import itertools
n = int(input())
arr = list(map(str, input().split()))
k = int(input())
st = ''
for i in arr:
	st += i
com = [list(itertools.combinations(st, x)) for x in range(1, len(st) + 1)]
scom = [''.join(e) for e in sum(com, [])]
cnt = 0
acnt = 0
for i in scom:
	if len(i) == k:
		cnt += 1
		if 'a' in i:
			acnt += 1
x = acnt / cnt
g = float('{0:.4f}'.format(x))
print(g)


import sys
from math import factorial

def C(n, k):
	return factorial(n) / (factorial(k) * factorial(n - k))

def ans(n, k, x):
	if n - x - k >= 0:
		return 1 - C(n - x, k) / C(n, k)
	else:
		return 1
rl = lambda : sys.stdin.readline()
n = int(rl())
s = rl().split()
x = s.count('a')
k = int(rl())
print('{:.4f}'.format(ans(n, k, x)))