#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
static const unsigned MODVAL = 1000000007;
struct mint
{
unsigned val;
mint():val(0){}
mint(int x):val(x%MODVAL) {}
mint(unsigned x):val(x%MODVAL) {}
mint(LL x):val(x%MODVAL) {}
};
mint& operator+=(mint& x, mint y) { return x = x.val+y.val; }
mint& operator-=(mint& x, mint y) { return x = x.val-y.val+MODVAL; }
mint& operator*=(mint& x, mint y) { return x = LL(x.val)*y.val; }
mint operator+(mint x, mint y) { return x+=y; }
mint operator-(mint x, mint y) { return x-=y; }
mint operator*(mint x, mint y) { return x*=y; }
vector< vector<mint> > CP_;
mint C(int n, int k) {
while( CP_.size() <= n ) {
int nn = CP_.size();
CP_.push_back(vector<mint>(nn+1,1));
for(int kk=1; kk<nn; ++kk)
CP_[nn][kk] = CP_[nn-1][kk-1] + CP_[nn-1][kk];
}
return k<0 || n<k ? 0 : CP_[n][k];
}
class LISNumber { public:
int count(vector <int> cardsnum, int K)
{
memo.assign(accumulate(cardsnum.begin(), cardsnum.end(), 1)*cardsnum.size(), -1);
return rec(1, 0, cardsnum, 0, K);
}
vector<int> memo;
int rec(int blks, int may, const vector<int>& cards, int i, int K)
{
if(i == cards.size())
return (K == may);
if(K<may)
return 0;
int key = may*cards.size() + i;
if(memo[key] != -1)
return memo[key];
int c = cards[i];
mint total = 0;
for(int use=1; use<=blks && use<=c; ++use)
{
for(int use_may=0; use_may<=use; ++use_may)
if(use-use_may<=blks-may && use_may<=may)
total += C(blks-may, use-use_may) * C(may, use_may) * C(c-1, use-1) * rec(blks+c,may-use_may+c,cards,i+1,K);
}
return memo[key] = total.val;
}
};
// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
{ ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
{ os << "{ ";
for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const int& Expected, const int& Received) {
bool ok = (Expected == Received);
if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl;
cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END verify_case(_, LISNumber().count(cardsnum, K));}
int main(){
/*
CASE(0)
int cardsnum_[] = {1, 1, 1};
vector <int> cardsnum(cardsnum_, cardsnum_+sizeof(cardsnum_)/sizeof(*cardsnum_));
int K = 2;
int _ = 4;
END
*/
CASE(1)
int cardsnum_[] = {2};
vector <int> cardsnum(cardsnum_, cardsnum_+sizeof(cardsnum_)/sizeof(*cardsnum_));
int K = 1;
int _ = 0;
END
CASE(2)
int cardsnum_[] = {36, 36, 36, 36, 36};
vector <int> cardsnum(cardsnum_, cardsnum_+sizeof(cardsnum_)/sizeof(*cardsnum_));
int K = 36;
int _ = 1;
END
CASE(3)
int cardsnum_[] = {3, 2, 11, 5, 7};
vector <int> cardsnum(cardsnum_, cardsnum_+sizeof(cardsnum_)/sizeof(*cardsnum_));
int K = 20;
int _ = 474640725;
END
CASE(4)
int cardsnum_[] = {31, 4, 15, 9, 26, 5, 35, 8, 9, 7, 9, 32, 3, 8, 4, 6, 26};
vector <int> cardsnum(cardsnum_, cardsnum_+sizeof(cardsnum_)/sizeof(*cardsnum_));
int K = 58;
int _ = 12133719;
END
CASE(5)
int cardsnum_[] = {27, 18, 28, 18, 28, 4, 5, 9, 4, 5, 23, 5,
36, 28, 7, 4, 7, 13, 5, 26, 6, 24, 9, 7,
7, 5, 7, 24, 7, 9, 36, 9, 9, 9, 5, 9};
vector <int> cardsnum(cardsnum_, cardsnum_+sizeof(cardsnum_)/sizeof(*cardsnum_));
int K = 116;
int _ = 516440918;
END
CASE(6)
int cardsnum_[] = {
36,36,36,36,36,36,
36,36,36,36,36,36,
36,36,36,36,36,36,
36,36,36,36,36,36,
36,36,36,36,36,36,
36,36,36,36,36,36};
vector <int> cardsnum(cardsnum_, cardsnum_+sizeof(cardsnum_)/sizeof(*cardsnum_));
int K = 36*36;
int _ = -1;
END
/*
CASE(7)
int cardsnum_[] = ;
vector <int> cardsnum(cardsnum_, cardsnum_+sizeof(cardsnum_)/sizeof(*cardsnum_));
int K = ;
int _ = ;
END
*/
}
// END CUT HERE