One of the first formulas we were taught in high school mathematics is
.
Later on, we learned that this is a special case of the expansion
,
in which the coefficient of
is the number of combinations of
things taken
at a time. We never learned (at least I never did...) what happens if instead
of a binomial
we have a multinomial
.
Your task is to write a program that, given a multinomial
,
,
computes the coefficient of a given term in the expansion of
,
.
The given term is specified by a sequence of
integer numbers
,
,
,
,
representing the powers of
,
,
,
in the expansion. Note that
.
For example, the coefficient of
in
is
.
The input file contains several test cases, each of them with three lines. The first line
contains a number representing the value of
.
The second line contains a number representing the value of
.
The third line contains
numbers, representing the values of
,
,
,
.
All test cases are such that
and the computed coefficient is less than
.
For each test case, write to the output one line. This line contains
one integer number representing the value of the coefficient of the term
in the expansion of
.
4
3
1 2 1
12
7
4
2 3 0 2
210