#include <iostream>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
map<int,int>mp;
int n,k;
vector<int>vec;
long long mo=1000000007;
long long dp[530][530];
bool lucky(int a)
{
    while(a)
    {
        if(a%10!=7 && a%10!=4)
        return 0;
        a/=10;
    }
    return 1;
}
long long po(long long a,long long b)
{
    if(b==1LL)
    return a;
    if(!b)return 1LL;
    long long p=po(a,b/2LL)%mo;
    if(b & 1LL)
    return (((p*p)%mo)*a)%mo;
    return ((p*p)%mo);
}
int c(int a,int b)
{
    map<int,int>m;
    map<int,int>:: iterator it;
    long long l=max(b,a-b);
    long long ll=min(b,a-b);
    for(int i=a;i>l;i--)
    {
        int p=i;
        for(int j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]++;
                p/=j;
            }
        }
        if(p > 1)
        m[p]++;
    }
    cout<<m[2]<<endl;
    for(int i=ll;i>=2;i--)
    {
        int p=i;
        for(int j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]--;
                p/=j;
            }
        }
        if(p > 1)
        m[p]--;
    }
    long long sum=1LL;
    for(it =m.begin();it!=m.end();it++)
    {
        sum*=po((*it).first,(*it).second);
        sum%=mo;
    }
    return sum%mo;
}
long long f(int u,int b)
{
    //cout<<u<<" "<<b<<endl;
    if(b==k)
    return 1LL;
    if(u==vec.size())
    {
        if(mp[1] >= k-b)
        return c(mp[1],k-b);
        else if(b==k)
        return 1LL;
        return 0LL;
    }
    if(dp[u][b] >= 0)
    return dp[u][b];
    long long sum=0LL;
    sum+=((f(u+1,b+1)*mp[vec[u]])%mo);
    sum+=(f(u+1,b)%mo);
    sum%=mo;
    return dp[u][b]=sum;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
    {
        int kk;
        cin>>kk;
        bool b=lucky(kk);
        if(mp[kk]==0 && b)
        {
            vec.push_back(kk);
            mp[kk]++;
        }
        else if(!b)
        {
            if(mp[1]==0)
            vec.push_back(1);
            mp[1]++;
        }
        else
        mp[kk]++;
    }
    sort(vec.begin(),vec.end());
    int p=0;
    if(mp[1])
    p++;
    int sum=f(p,0)%mo;
    //cout<<c(100,20)<<endl;
    cout<<sum<<endl;
}


#include <iostream>
#include <map>
#include <cmath>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
map<int,long long>mp;
int n,k;
vector<int>vec;
long long mo=1000000007;
long long dp[530][530];
bool lucky(int a)
{
    while(a)
    {
        if(a%10!=7 && a%10!=4)
        return 0;
        a/=10;
    }
    return 1;
}
long long po(long long a,long long b)
{
    if(b==1LL)
    return a;
    if(!b)return 1LL;
    long long p=po(a,b/2LL)%mo;
    if(b & 1LL)
    return (((p*a)%mo)*p)%mo;
    return ((p*p)%mo);
}
int c(int a,int b)
{
    map<int,int>m;
    map<int,int>:: iterator it;
    long long l=max(b,a-b);
    long long ll=min(b,a-b);
    for(int i=a;i>l;i--)
    {
        int p=i;
        for(int j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]++;
                p/=j;
            }
        }
        if(p > 1)
        m[p]++;
    }
    for(int i=ll;i>=2;i--)
    {
        int p=i;
        for(int j=2;j<=sqrt(p);j++)
        {
            while(p%j==0)
            {
                m[j]--;
                p/=j;
            }
        }
        if(p > 1)
        m[p]--;
    }
    long long sum=1LL;
    for(it =m.begin();it!=m.end();it++)
    {
        sum*=po((*it).first,(*it).second);
        sum%=mo;
    }
    return sum%mo;
}
long long f(int u,int b)
{
    if(b==k)
    return 1LL;
    if(u==vec.size())
    {
        if(mp[1] >= k-b)
        return c(mp[1],k-b);
        return 0LL;
    }
    if(dp[u][b] >= 0)
    return dp[u][b];
    long long sum=0LL;
    sum+=((f(u+1,b+1)*mp[vec[u]])%mo);
    sum%=mo;
    sum+=(f(u+1,b)%mo);
    sum%=mo;
    return dp[u][b]=sum;
}
int main()
{
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)
    {
        int kk;
        cin>>kk;
        bool b=lucky(kk);
        if(mp[kk]==0 && b)
        {
            vec.push_back(kk);
            mp[kk]++;
        }
        else if(!b)
        {
            mp[1]++;
        }
        else
        mp[kk]++;
    }
    long long sum=f(0,0)%mo;
    cout<<sum<<endl;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#define N 100005
#define mod 1000000007
typedef long long LL;
using namespace std;
map<int,int>h;
int n,K,un;
int p[N];
bool check(int x)
{
    if(x<4)return false;
    while(x)
    {
        if(x%10!=4 && x%10!=7)return false;
        x/=10;
    }
    return true;
}
int extgcd(int a, int b, int & x, int & y)
{
    if (b == 0)
    {
        x=1;
        y=0;
        return a;
    }
    int d = extgcd(b, a % b, x, y);
    int t = x;
    x = y;
    y = t - a / b * y;
    return d;
}
int inv(int a)
{
    int x,y;
    extgcd(a,mod,x,y);
    while(x<0)x+=mod;
    return x;
}
void init()
{
    p[0]=1;
    for(int i=1;i<N;i++)
    {
        p[i]=(p[i-1]*(LL)(i))%(LL)(mod);
    }
}
LL com(int n,int m)
{
    LL t=p[n];
    t=(t*inv(p[m]))%mod;
    t=(t*inv(p[n-m]))%mod;
    return t;
}
int dp[1100][1100];
LL s[1100];
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    #endif
    init();

    scanf("%d %d",&n,&K);
    int x;
    un=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if(check(x))
        {
            h[x]++;
        }else un++;
    }
    map<int,int>::iterator it=h.begin();
    int l=0;
    for(;it!=h.end();it++)
    {
        s[++l]=it->second;
    }
    for(int i=0;i<=l;i++)
        dp[i][0]=1;
    for(int i=1;i<=l;i++)
        for(int j=1;j<=i;j++)
        {
            dp[i][j]=(dp[i-1][j]+(dp[i-1][j-1]*s[i])%mod)%mod;
        }
    int ans=0;
    for(int i=0;i<=min(l,K);i++)
    {
        ans+=(dp[l][i]*com(un,K-i))%mod;
        ans%=mod;
    }
    printf("%d\n",ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#define N 100005
#define mod 1000000007
typedef long long LL;
using namespace std;
map<int,int>h;
int n,K,un;
int p[N];
bool check(int x)
{
    if(x<4)return false;
    while(x)
    {
        if(x%10!=4 && x%10!=7)return false;
        x/=10;
    }
    return true;
}
int extgcd(int a, int b, int & x, int & y)
{
    if (b == 0)
    {
        x=1;
        y=0;
        return a;
    }
    int d = extgcd(b, a % b, x, y);
    int t = x;
    x = y;
    y = t - a / b * y;
    return d;
}
int inv(int a)
{
    int x,y;
    extgcd(a,mod,x,y);
    while(x<0)x+=mod;
    return x;
}
void init()
{
    p[0]=1;
    for(int i=1;i<N;i++)
    {
        p[i]=(p[i-1]*(LL)(i))%(LL)(mod);
    }
}
LL com(int n,int m)
{
    if(m>n)return 0;
    LL t=p[n];
    t=(t*inv(p[m]))%mod;
    t=(t*inv(p[n-m]))%mod;
    return t;
}
int dp[1100][1100];
LL s[1100];
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    #endif
    init();

    scanf("%d %d",&n,&K);
    int x;
    un=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if(check(x))
        {
            h[x]++;
        }else un++;
    }
    map<int,int>::iterator it=h.begin();
    int l=0;
    for(;it!=h.end();it++)
    {
        s[++l]=it->second;
    }
    for(int i=0;i<=l;i++)
        dp[i][0]=1;
    for(int i=1;i<=l;i++)
        for(int j=1;j<=i;j++)
        {
            dp[i][j]=(dp[i-1][j]+(dp[i-1][j-1]*s[i])%mod)%mod;
        }
    int ans=0;
    for(int i=0;i<=min(l,K);i++)
    {
        ans+=(dp[l][i]*com(un,K-i))%mod;
        ans%=mod;
    }
    printf("%d\n",ans);
    return 0;
}


/*
	Codeforces Round #104 (Div. 2) Problem E
	created on 2012.1.22
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#define ll long long
#define oo 1000000007
#define min(a,b) (a)<(b)?(a):(b)
using namespace std;
map <int,int> a;
int f[10005];
ll g[100005],c[100005],s[10005];
ll mul(ll x,int y)
{
	ll z=1;
	while (y){
		if (y&1) z=(z*x)%oo;
		y/=2; x=(x*x)%oo;
		}
	return z;
}
int main()
{
	int h=0,t=1; f[1]=0;
	while (h<t){
		int i=f[++h]; if (i>100000000) continue;
		f[++t]=i*10+4; f[++t]=i*10+7;
		}
	for (int i=2;i<=t;i++) a[f[i]]=i-1;

	int n,k,x,y; scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d",&x);
		if (a.find(x)==a.end()) y=0;
		else y=a[x];
		s[y]++;
		}

	int sum=0; g[0]=1;
	for (int i=1;i<=t;i++) if (s[i]){
		sum++;
		for (int j=sum;j>=1;j--)
			g[j]=g[j]+g[j-1]*s[i];
		}

	ll z=1; c[0]=1;
	for (int i=s[0];i;i--){
		c[i]=z; z=z*i%oo;
		z=z*mul(s[0]-i+1,oo-2)%oo;
		}
	ll ans=0;
	for (int i=0;i<=(min(sum,k));i++) ans=(ans+g[i]*c[k-i])%oo;
	printf("%d\n",ans);
	return 0;
}


/*
	Codeforces Round #104 (Div. 2) Problem E
	created on 2012.1.22
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#define ll long long
#define oo 1000000007
#define min(a,b) (a)<(b)?(a):(b)
using namespace std;
map <int,int> a;
int f[10005];
ll g[1500][1500],c[100005],s[10005];
ll mul(ll x,int y)
{
	ll z=1;
	while (y){
		if (y&1) z=(z*x)%oo;
		y/=2; x=(x*x)%oo;
		}
	return z;
}
int main()
{
	//freopen("E.in","r",stdin);
	//freopen("E.out","w",stdout);
	int h=0,t=1; f[1]=0;
	while (h<t){
		int i=f[++h]; if (i>100000000) continue;
		f[++t]=i*10+4; f[++t]=i*10+7;
		}
	for (int i=2;i<=t;i++) a[f[i]]=i-1;

	int n,k,x,y; scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d",&x);
		if (a.find(x)==a.end()) y=0;
		else y=a[x];
		s[y]++;
		}

	int sum=0; g[0][0]=1;
	for (int i=1;i<=t;i++) if (s[i]){
		sum++; g[sum][0]=1;
		for (int j=1;j<=sum;j++){
			g[sum][j]=g[sum-1][j];
			g[sum][j]=(g[sum][j]+g[sum-1][j-1]*s[i])%oo;
			}
		}

	ll z=1; c[0]=1;
	for (int i=s[0];i;i--){
		c[i]=z; z=z*i%oo;
		z=z*mul(s[0]-i+1,oo-2)%oo;
		z=(z+oo)%oo;
		}
	ll ans=0;
	for (int i=0;i<=(min(sum,k));i++) ans=(ans+g[sum][i]*c[k-i])%oo;
	printf("%d\n",(ans+oo)%oo);
	return 0;
}


/*
	Codeforces Round #104 (Div. 2) Problem E
	created on 2012.1.22
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#define ll long long
#define oo 1000000007
#define min(a,b) (a)<(b)?(a):(b)
using namespace std;
map <int,int> a;
int f[10005];
ll g[100005],c[100005],s[10005];
ll mul(ll x,int y)
{
	ll z=1;
	while (y){
		if (y&1) z=(z*x)%oo;
		y/=2; x=(x*x)%oo;
		}
	return z;
}
int main()
{
	//freopen("E.in","r",stdin);
	//freopen("E.out","w",stdout);
	int h=0,t=1; f[1]=0;
	while (h<t){
		int i=f[++h]; if (i>100000000) continue;
		f[++t]=i*10+4; f[++t]=i*10+7;
		}
	for (int i=2;i<=t;i++) a[f[i]]=i-1;

	int n,k,x,y; scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d",&x);
		if (a.find(x)==a.end()) y=0;
		else y=a[x];
		s[y]++;
		}

	int sum=0; g[0]=1;
	for (int i=1;i<=t;i++) if (s[i]){
		sum++;
		for (int j=sum;j>=1;j--)
			g[j]=g[j]+g[j-1]*s[i];
		}

	ll z=1; c[0]=1;
	for (int i=s[0];i;i--){
		c[i]=z; z=z*i%oo;
		z=z*mul(s[0]-i+1,oo-2)%oo;
		}
	ll ans=0;
	for (int i=0;i<=(min(sum,k));i++) ans=(ans+g[i]*c[k-i])%oo;
	printf("%d\n",(ans+oo)%oo);
	return 0;
}


/// بسم الله الرحمن الرحيم

/* *********************************************************************
   *                       JU_Undefined_Coders                         *
   *               Team Members: Shaheen, Niloy, B'ru                  *
   ********************************************************************* */

#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define I1(n) scanf("%d",&n)
#define LL1(n) scanf("%lld",&n)
#define I2(n1,n2) scanf("%d%d",&n1,&n2)
#define LL2(n1,n2) scanf("%lld%lld",&n1,&n2)
#define I3(n1,n2,n3) scanf("%d%d%d",&n1,&n2,&n3)
#define LL3(n1,n2,n3) scanf("%lld%lld%lld",&n1,&n2,&n3)

#define  F(i,a,b) for(i=a;i<b; i++)
#define FF(i,a,b) for(i=a;i<=b;i++)
#define FI(i,a,b) for((typeof(b)) i=a;i<=b;i++)
#define FR(i, a, b,inc) for(  i = (a); i <= (b); i+=inc )
#define RFR(i, a, b,dec) for(  i = (a); i >= (b); i-=dec )
#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) cout << *it << " "; cout << endl;

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n) (n*n)
#define PI 2.0*acos(0.0) //#define PI acos(-1.0)

#define all(a) a.begin(),a.end()
#define X first
#define Y second

#define PCC cout<<"Case "<<cas++<<": ";
#define PC printf("Case %d:",cas++);
#define PCN printf("Case %d:\n",cas++);
#define NL printf("\n");
#define cp printf("here\n");

#define SET(a,i) memset(a,i,sizeof a)
#define MEM(a,val) memset(a,val,sizeof(a))
#define open freopen("input.txt","r",stdin)
#define close freopen ("output.txt","w",stdout)
#define Case(a) printf("Case %d:",a)
#define caseh(a) printf("Case #%d: ",a)
#define S1(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SL1(a) scanf("%lld",&a)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR getchar()
#define PB(x) push_back(x)
#define pb push_back
#define PP pop_back()
#define PF(x) push_front(x)
#define PPF(x) pop_front()
#define PS(x) push(x)
#define sz() size()
#define UB upper_bound
#define LB lower_bound
#define mxe(a,n) (*max_element(a,a+n))
#define mne(a,n) (*min_element(a,a+n))
#define SUM(a,n) (accumulate(a,a+n,0))
#define onbits  __builtin_popcount
#define VI vector<int>
#define DBG(n) P("Done %d\n",n);

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template<typename T>inline T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template<typename T>inline T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template<typename T>inline T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template<typename T>inline T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T>inline T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template<typename T>inline T ABS(T a) {if(a<0)return -a;else return a;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template<typename T>inline T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}

int Set(int N,int pos){ return N=N | (1<<pos);}
int Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

/* ------------------------------------------------------------------------------------------------------- */
//          0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

int DD[12][2][10];
//int a[] = {1,0,0,0,0,0,0,0,0,0};
LL DP[1024][1024];
int cnt[1024];
int a[1024];
LL Fact[MX];

void Count(int n){

    for (int p=n;p>=0;p--){
        for (int c=0;c<2;c++){
            for (int d=0;d<2;d++){
                if (p == n)         DD[p][c][d] = 1;
                else{
                    DD[p][c][d] = 0;

                    if (!d)                 DD[p][c][d] += DD[p+1][c|(0<a[p])][d];
                    if (c || 4<=a[p])       DD[p][c][d] += DD[p+1][c|(4<a[p])][1];
                    if (c || 7<=a[p])       DD[p][c][d] += DD[p+1][c|(7<a[p])][1];
                }
            }
        }
    }
}

void dp(int n,int k,int m){
    int can = min(n,k);

    for (int p=n;p>=0;p--){
        for (int c=0;c<=can;c++){
            if (p == n){
                int lagbe = k-c;

                if (lagbe > m)      DP[p][c] = 0;
                else{
                    LL tmp = Fact[m];
                    tmp = (tmp * ModInv(Fact[lagbe],(LL)MOD))%MOD;
                    tmp = (tmp * ModInv(Fact[m-lagbe],(LL)MOD))%MOD;

                    DP[p][c] = tmp;
                }
            }

            else{
                DP[p][c] = DP[p+1][c];

                DP[p][c] = (DP[p][c] + (DP[p+1][c+1]*cnt[p])%MOD)%MOD;
            }
        }
    }
}

void f(){
    Fact[0] = 1;

    for (int i=1;i<MX;i++)      Fact[i] = (Fact[i-1] * i)%MOD;
}

bool Lucky(int n){
    while (n){
        int x = n%10; n /= 10;

        if (x != 4 && x != 7)       return 0;
    }

    return 1;
}

int main()
{
//    Count(10);
//    cout << DP[0][0][0] << endl;

    int n,k,m=0,p=0;
    int unLucky = 0;

    S2(n,k);

    for (int i=1;i<=n;i++){
        int x;

        S1(x);

        if (Lucky(x))       a[p++] = x;
        else                unLucky++;
    }

    sort(a,a+p);

    if (p)  cnt[0] = 1;

    for (int i=1;i<p;i++){
        if (a[i] != a[i-1]) m ++;

        cnt[m]++;
    }

    if (n == 10000 && k ==5845) cout << m << endl;

    //cout << "OK!\n";

    f();        //cout << "FCT\n";
    dp(m+1,k,unLucky);      //cout << "DP\n";

    cout << DP[0][0] << endl;
    return 0;

return 0;
}


/// بسم الله الرحمن الرحيم

/* *********************************************************************
   *                       JU_Undefined_Coders                         *
   *               Team Members: Shaheen, Niloy, B'ru                  *
   ********************************************************************* */

#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define I1(n) scanf("%d",&n)
#define LL1(n) scanf("%lld",&n)
#define I2(n1,n2) scanf("%d%d",&n1,&n2)
#define LL2(n1,n2) scanf("%lld%lld",&n1,&n2)
#define I3(n1,n2,n3) scanf("%d%d%d",&n1,&n2,&n3)
#define LL3(n1,n2,n3) scanf("%lld%lld%lld",&n1,&n2,&n3)

#define  F(i,a,b) for(i=a;i<b; i++)
#define FF(i,a,b) for(i=a;i<=b;i++)
#define FI(i,a,b) for((typeof(b)) i=a;i<=b;i++)
#define FR(i, a, b,inc) for(  i = (a); i <= (b); i+=inc )
#define RFR(i, a, b,dec) for(  i = (a); i >= (b); i-=dec )
#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) cout << *it << " "; cout << endl;

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n) (n*n)
#define PI 2.0*acos(0.0) //#define PI acos(-1.0)

#define all(a) a.begin(),a.end()
#define X first
#define Y second

#define PCC cout<<"Case "<<cas++<<": ";
#define PC printf("Case %d:",cas++);
#define PCN printf("Case %d:\n",cas++);
#define NL printf("\n");
#define cp printf("here\n");

#define SET(a,i) memset(a,i,sizeof a)
#define MEM(a,val) memset(a,val,sizeof(a))
#define open freopen("input.txt","r",stdin)
#define close freopen ("output.txt","w",stdout)
#define Case(a) printf("Case %d:",a)
#define caseh(a) printf("Case #%d: ",a)
#define S1(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SL1(a) scanf("%lld",&a)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR getchar()
#define PB(x) push_back(x)
#define pb push_back
#define PP pop_back()
#define PF(x) push_front(x)
#define PPF(x) pop_front()
#define PS(x) push(x)
#define sz() size()
#define UB upper_bound
#define LB lower_bound
#define mxe(a,n) (*max_element(a,a+n))
#define mne(a,n) (*min_element(a,a+n))
#define SUM(a,n) (accumulate(a,a+n,0))
#define onbits  __builtin_popcount
#define VI vector<int>
#define DBG(n) P("Done %d\n",n);

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template<typename T>inline T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template<typename T>inline T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template<typename T>inline T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template<typename T>inline T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T>inline T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template<typename T>inline T ABS(T a) {if(a<0)return -a;else return a;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template<typename T>inline T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}

int Set(int N,int pos){ return N=N | (1<<pos);}
int Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

/* ------------------------------------------------------------------------------------------------------- */
//          0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

int DD[12][2][10];
//int a[] = {1,0,0,0,0,0,0,0,0,0};
LL DP[1024][1024];
int cnt[1024];
int a[1024];
LL Fact[MX];
map<int,int> ccc;

void Count(int n){

    for (int p=n;p>=0;p--){
        for (int c=0;c<2;c++){
            for (int d=0;d<2;d++){
                if (p == n)         DD[p][c][d] = 1;
                else{
                    DD[p][c][d] = 0;

                    if (!d)                 DD[p][c][d] += DD[p+1][c|(0<a[p])][d];
                    if (c || 4<=a[p])       DD[p][c][d] += DD[p+1][c|(4<a[p])][1];
                    if (c || 7<=a[p])       DD[p][c][d] += DD[p+1][c|(7<a[p])][1];
                }
            }
        }
    }
}

void dp(int n,int k,int m){
    int can = min(n,k);

    for (int p=n;p>=0;p--){
        for (int c=0;c<=can;c++){
            if (p == n){
                int lagbe = k-c;

                if (lagbe > m)      DP[p][c] = 0;
                else{
                    LL tmp = Fact[m];
                    tmp = (tmp * ModInv(Fact[lagbe],(LL)MOD))%MOD;
                    tmp = (tmp * ModInv(Fact[m-lagbe],(LL)MOD))%MOD;

                    DP[p][c] = tmp;
                }
            }

            else{
                DP[p][c] = DP[p+1][c];

                DP[p][c] = (DP[p][c] + (DP[p+1][c+1]*cnt[p])%MOD)%MOD;
            }
        }
    }
}

void f(){
    Fact[0] = 1;

    for (int i=1;i<MX;i++)      Fact[i] = (Fact[i-1] * i)%MOD;
}

bool Lucky(int n){
    while (n){
        int x = n%10; n /= 10;

        if (x != 4 && x != 7)       return 0;
    }

    return 1;
}

int main()
{
//    Count(10);
//    cout << DP[0][0][0] << endl;

    int n,k,m=0,p=0;
    int unLucky = 0;

    S2(n,k);

    for (int i=1;i<=n;i++){
        int x;

        S1(x);

        if (Lucky(x))       ccc[x]++;
        else                unLucky++;
    }

    for(map<int,int>::iterator it = ccc.begin();it!=ccc.end();it++){
        cnt[m++] = (*it).second;
    }

//    if (p)  cnt[0] = 1;
//
//    for (int i=1;i<p;i++){
//        if (a[i] != a[i-1]) m ++;
//
//        cnt[m]++;
//    }

//    if (n == 10000 && k ==5845) cout << m << endl;

    //cout << "OK!\n";

    f();        //cout << "FCT\n";
    dp(m,k,unLucky);      //cout << "DP\n";

    cout << DP[0][0] << endl;
    return 0;

return 0;
}


/// بسم الله الرحمن الرحيم

/* *********************************************************************
   *                       JU_Undefined_Coders                         *
   *               Team Members: Shaheen, Niloy, B'ru                  *
   ********************************************************************* */

#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define I1(n) scanf("%d",&n)
#define LL1(n) scanf("%lld",&n)
#define I2(n1,n2) scanf("%d%d",&n1,&n2)
#define LL2(n1,n2) scanf("%lld%lld",&n1,&n2)
#define I3(n1,n2,n3) scanf("%d%d%d",&n1,&n2,&n3)
#define LL3(n1,n2,n3) scanf("%lld%lld%lld",&n1,&n2,&n3)

#define  F(i,a,b) for(i=a;i<b; i++)
#define FF(i,a,b) for(i=a;i<=b;i++)
#define FI(i,a,b) for((typeof(b)) i=a;i<=b;i++)
#define FR(i, a, b,inc) for(  i = (a); i <= (b); i+=inc )
#define RFR(i, a, b,dec) for(  i = (a); i >= (b); i-=dec )
#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) cout << *it << " "; cout << endl;

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n) (n*n)
#define PI 2.0*acos(0.0) //#define PI acos(-1.0)

#define all(a) a.begin(),a.end()
#define X first
#define Y second

#define PCC cout<<"Case "<<cas++<<": ";
#define PC printf("Case %d:",cas++);
#define PCN printf("Case %d:\n",cas++);
#define NL printf("\n");
#define cp printf("here\n");

#define SET(a,i) memset(a,i,sizeof a)
#define MEM(a,val) memset(a,val,sizeof(a))
#define open freopen("input.txt","r",stdin)
#define close freopen ("output.txt","w",stdout)
#define Case(a) printf("Case %d:",a)
#define caseh(a) printf("Case #%d: ",a)
#define S1(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SL1(a) scanf("%lld",&a)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR getchar()
#define PB(x) push_back(x)
#define pb push_back
#define PP pop_back()
#define PF(x) push_front(x)
#define PPF(x) pop_front()
#define PS(x) push(x)
#define sz() size()
#define UB upper_bound
#define LB lower_bound
#define mxe(a,n) (*max_element(a,a+n))
#define mne(a,n) (*min_element(a,a+n))
#define SUM(a,n) (accumulate(a,a+n,0))
#define onbits  __builtin_popcount
#define VI vector<int>
#define DBG(n) P("Done %d\n",n);

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template<typename T>inline T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template<typename T>inline T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template<typename T>inline T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template<typename T>inline T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T>inline T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template<typename T>inline T ABS(T a) {if(a<0)return -a;else return a;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template<typename T>inline T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}

int Set(int N,int pos){ return N=N | (1<<pos);}
int Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

/* ------------------------------------------------------------------------------------------------------- */
//          0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

int DD[12][2][10];
//int a[] = {1,0,0,0,0,0,0,0,0,0};
LL DP[1024][1024];
int cnt[1024];
int a[1024];
LL Fact[MX];

void Count(int n){

    for (int p=n;p>=0;p--){
        for (int c=0;c<2;c++){
            for (int d=0;d<2;d++){
                if (p == n)         DD[p][c][d] = 1;
                else{
                    DD[p][c][d] = 0;

                    if (!d)                 DD[p][c][d] += DD[p+1][c|(0<a[p])][d];
                    if (c || 4<=a[p])       DD[p][c][d] += DD[p+1][c|(4<a[p])][1];
                    if (c || 7<=a[p])       DD[p][c][d] += DD[p+1][c|(7<a[p])][1];
                }
            }
        }
    }
}

void dp(int n,int k,int m){
    int can = min(n,k);

    for (int p=n;p>=0;p--){
        for (int c=0;c<=can;c++){
            if (p == n){
                int lagbe = k-c;

                if (lagbe > m)      DP[p][c] = 0;
                else{
                    LL tmp = Fact[m];
                    tmp = (tmp * ModInv(Fact[lagbe],(LL)MOD))%MOD;
                    tmp = (tmp * ModInv(Fact[m-lagbe],(LL)MOD))%MOD;

                    DP[p][c] = tmp;
                }
            }

            else{
                DP[p][c] = DP[p+1][c];

                DP[p][c] = (DP[p][c] + (DP[p+1][c+1]*cnt[p])%MOD)%MOD;
            }
        }
    }
}

void f(){
    Fact[0] = 1;

    for (int i=1;i<MX;i++)      Fact[i] = (Fact[i-1] * i)%MOD;
}

bool Lucky(int n){
    while (n){
        int x = n%10; n /= 10;

        if (x != 4 && x != 7)       return 0;
    }

    return 1;
}

int main()
{
//    Count(10);
//    cout << DP[0][0][0] << endl;

    int n,k,m=0,p=0;
    int unLucky = 0;

    S2(n,k);

    for (int i=1;i<=n;i++){
        int x;

        S1(x);

        if (Lucky(x))       a[p++] = x;
        else                unLucky++;
    }

    sort(a,a+p);

    if (p)  cnt[0] = 1;

    for (int i=1;i<p;i++){
        if (a[i] != a[i-1]){
            cnt[++m] = 1;
        }

        else cnt[m]++;
    }

    //cout << "OK!\n";

    f();        //cout << "FCT\n";
    dp(m+1,k,unLucky);      //cout << "DP\n";

    cout << DP[0][0] << endl;
    return 0;

    LL ans = 0;

//    for (int i=1;i<=m;i++)  cout << cnt[i] << endl;

    for (int i=0;i<=min(m,k);i++){

//        cout << DP[m][i] << endl;
//        cout << unLucky << "C" << k-i << endl;
        if (k-i > unLucky)      continue;
        LL tmp = ((DP[m][i]-DP[m][i-1]) * Fact[unLucky])%MOD;       //cout << "---" << tmp << endl;
        tmp = (tmp * ModInv(Fact[k-i],(LL)MOD))%MOD;                //cout << "---" << tmp << endl;
        tmp = (tmp * ModInv(Fact[unLucky-(k-i)],(LL)MOD))%MOD;      //cout << "---" << tmp << endl;

        ans = (ans + tmp)%MOD;
    }

    cout << ans << endl;

return 0;
}


/// بسم الله الرحمن الرحيم

/* *********************************************************************
   *                       JU_Undefined_Coders                         *
   *               Team Members: Shaheen, Niloy, B'ru                  *
   ********************************************************************* */

#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define I1(n) scanf("%d",&n)
#define LL1(n) scanf("%lld",&n)
#define I2(n1,n2) scanf("%d%d",&n1,&n2)
#define LL2(n1,n2) scanf("%lld%lld",&n1,&n2)
#define I3(n1,n2,n3) scanf("%d%d%d",&n1,&n2,&n3)
#define LL3(n1,n2,n3) scanf("%lld%lld%lld",&n1,&n2,&n3)

#define  F(i,a,b) for(i=a;i<b; i++)
#define FF(i,a,b) for(i=a;i<=b;i++)
#define FI(i,a,b) for((typeof(b)) i=a;i<=b;i++)
#define FR(i, a, b,inc) for(  i = (a); i <= (b); i+=inc )
#define RFR(i, a, b,dec) for(  i = (a); i >= (b); i-=dec )
#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) cout << *it << " "; cout << endl;

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n) (n*n)
#define PI 2.0*acos(0.0) //#define PI acos(-1.0)

#define all(a) a.begin(),a.end()
#define X first
#define Y second

#define PCC cout<<"Case "<<cas++<<": ";
#define PC printf("Case %d:",cas++);
#define PCN printf("Case %d:\n",cas++);
#define NL printf("\n");
#define cp printf("here\n");

#define SET(a,i) memset(a,i,sizeof a)
#define MEM(a,val) memset(a,val,sizeof(a))
#define open freopen("input.txt","r",stdin)
#define close freopen ("output.txt","w",stdout)
#define Case(a) printf("Case %d:",a)
#define caseh(a) printf("Case #%d: ",a)
#define S1(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SL1(a) scanf("%lld",&a)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR getchar()
#define PB(x) push_back(x)
#define pb push_back
#define PP pop_back()
#define PF(x) push_front(x)
#define PPF(x) pop_front()
#define PS(x) push(x)
#define sz() size()
#define UB upper_bound
#define LB lower_bound
#define mxe(a,n) (*max_element(a,a+n))
#define mne(a,n) (*min_element(a,a+n))
#define SUM(a,n) (accumulate(a,a+n,0))
#define onbits  __builtin_popcount
#define VI vector<int>
#define DBG(n) P("Done %d\n",n);

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template<typename T>inline T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template<typename T>inline T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template<typename T>inline T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template<typename T>inline T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T>inline T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template<typename T>inline T ABS(T a) {if(a<0)return -a;else return a;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template<typename T>inline T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}

int Set(int N,int pos){ return N=N | (1<<pos);}
int Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

/* ------------------------------------------------------------------------------------------------------- */
//          0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

int DD[12][2][10];
//int a[] = {1,0,0,0,0,0,0,0,0,0};
LL DP[1024][1024];
int cnt[1024];
int a[1024];
LL Fact[MX];
map<int,int> ccc;

void Count(int n){

    for (int p=n;p>=0;p--){
        for (int c=0;c<2;c++){
            for (int d=0;d<2;d++){
                if (p == n)         DD[p][c][d] = 1;
                else{
                    DD[p][c][d] = 0;

                    if (!d)                 DD[p][c][d] += DD[p+1][c|(0<a[p])][d];
                    if (c || 4<=a[p])       DD[p][c][d] += DD[p+1][c|(4<a[p])][1];
                    if (c || 7<=a[p])       DD[p][c][d] += DD[p+1][c|(7<a[p])][1];
                }
            }
        }
    }
}

void dp(int n,int k,int m){
    int can = min(n,k);

    for (int p=n;p>=0;p--){
        for (int c=0;c<=can;c++){
            if (p == n){
                int lagbe = k-c;

                if (lagbe > m)      DP[p][c] = 0;
                else{
                    LL tmp = Fact[m];
                    tmp = (tmp * ModInv(Fact[lagbe],(LL)MOD))%MOD;
                    tmp = (tmp * ModInv(Fact[m-lagbe],(LL)MOD))%MOD;

                    DP[p][c] = tmp;
                }
            }

            else{
                DP[p][c] = DP[p+1][c];

                DP[p][c] = (DP[p][c] + (DP[p+1][c+1]*cnt[p])%MOD)%MOD;
            }
        }
    }
}

void f(){
    Fact[0] = 1;

    for (int i=1;i<MX;i++)      Fact[i] = (Fact[i-1] * i)%MOD;
}

bool Lucky(int n){
    while (n){
        int x = n%10; n /= 10;

        if (x != 4 && x != 7)       return 0;
    }

    return 1;
}

int main()
{
//    Count(10);
//    cout << DP[0][0][0] << endl;

    int n,k,m=0,p=0;
    int unLucky = 0;

    S2(n,k);

    for (int i=1;i<=n;i++){
        int x;

        S1(x);

        if (Lucky(x))       ccc[x]++;
        else                unLucky++;
    }

    for(map<int,int>::iterator it = ccc.begin();it!=ccc.end();it++){
        cnt[m++] = (*it).second;
    }

//    if (p)  cnt[0] = 1;
//
//    for (int i=1;i<p;i++){
//        if (a[i] != a[i-1]) m ++;
//
//        cnt[m]++;
//    }

    if (n == 10000 && k ==5845) cout << m << endl;

    //cout << "OK!\n";

    f();        //cout << "FCT\n";
    dp(m,k,unLucky);      //cout << "DP\n";

    cout << DP[0][0] << endl;
    return 0;

return 0;
}


/// بسم الله الرحمن الرحيم

/* *********************************************************************
   *                       JU_Undefined_Coders                         *
   *               Team Members: Shaheen, Niloy, B'ru                  *
   ********************************************************************* */

#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define I1(n) scanf("%d",&n)
#define LL1(n) scanf("%lld",&n)
#define I2(n1,n2) scanf("%d%d",&n1,&n2)
#define LL2(n1,n2) scanf("%lld%lld",&n1,&n2)
#define I3(n1,n2,n3) scanf("%d%d%d",&n1,&n2,&n3)
#define LL3(n1,n2,n3) scanf("%lld%lld%lld",&n1,&n2,&n3)

#define  F(i,a,b) for(i=a;i<b; i++)
#define FF(i,a,b) for(i=a;i<=b;i++)
#define FI(i,a,b) for((typeof(b)) i=a;i<=b;i++)
#define FR(i, a, b,inc) for(  i = (a); i <= (b); i+=inc )
#define RFR(i, a, b,dec) for(  i = (a); i >= (b); i-=dec )
#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) cout << *it << " "; cout << endl;

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n) (n*n)
#define PI 2.0*acos(0.0) //#define PI acos(-1.0)

#define all(a) a.begin(),a.end()
#define X first
#define Y second

#define PCC cout<<"Case "<<cas++<<": ";
#define PC printf("Case %d:",cas++);
#define PCN printf("Case %d:\n",cas++);
#define NL printf("\n");
#define cp printf("here\n");

#define SET(a,i) memset(a,i,sizeof a)
#define MEM(a,val) memset(a,val,sizeof(a))
#define open freopen("input.txt","r",stdin)
#define close freopen ("output.txt","w",stdout)
#define Case(a) printf("Case %d:",a)
#define caseh(a) printf("Case #%d: ",a)
#define S1(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SL1(a) scanf("%lld",&a)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR getchar()
#define PB(x) push_back(x)
#define pb push_back
#define PP pop_back()
#define PF(x) push_front(x)
#define PPF(x) pop_front()
#define PS(x) push(x)
#define sz() size()
#define UB upper_bound
#define LB lower_bound
#define mxe(a,n) (*max_element(a,a+n))
#define mne(a,n) (*min_element(a,a+n))
#define SUM(a,n) (accumulate(a,a+n,0))
#define onbits  __builtin_popcount
#define VI vector<int>
#define DBG(n) P("Done %d\n",n);

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template<typename T>inline T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template<typename T>inline T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template<typename T>inline T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template<typename T>inline T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T>inline T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template<typename T>inline T ABS(T a) {if(a<0)return -a;else return a;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template<typename T>inline T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}

int Set(int N,int pos){ return N=N | (1<<pos);}
int Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

/* ------------------------------------------------------------------------------------------------------- */
//          0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

int DD[12][2][10];
//int a[] = {1,0,0,0,0,0,0,0,0,0};
LL DP[1024][1024];
int cnt[1024];
int a[1024];
LL Fact[MX];

void Count(int n){

    for (int p=n;p>=0;p--){
        for (int c=0;c<2;c++){
            for (int d=0;d<2;d++){
                if (p == n)         DD[p][c][d] = 1;
                else{
                    DD[p][c][d] = 0;

                    if (!d)                 DD[p][c][d] += DD[p+1][c|(0<a[p])][d];
                    if (c || 4<=a[p])       DD[p][c][d] += DD[p+1][c|(4<a[p])][1];
                    if (c || 7<=a[p])       DD[p][c][d] += DD[p+1][c|(7<a[p])][1];
                }
            }
        }
    }
}

void dp(int n,int k,int m){
    int can = min(n,k);

    for (int p=n;p>=0;p--){
        for (int c=0;c<=can;c++){
            if (p == n){
                int lagbe = k-c;

                if (lagbe > m)      DP[p][c] = 0;
                else{
                    LL tmp = Fact[m];
                    tmp = (tmp * ModInv(Fact[lagbe],(LL)MOD))%MOD;
                    tmp = (tmp * ModInv(Fact[m-lagbe],(LL)MOD))%MOD;

                    DP[p][c] = tmp;
                }
            }

            else{
                DP[p][c] = DP[p+1][c];

                DP[p][c] = (DP[p][c] + (DP[p+1][c+1]*cnt[p])%MOD)%MOD;
            }
        }
    }
}

void f(){
    Fact[0] = 1;

    for (int i=1;i<MX;i++)      Fact[i] = (Fact[i-1] * i)%MOD;
}

bool Lucky(int n){
    while (n){
        int x = n%10; n /= 10;

        if (x != 4 && x != 7)       return 0;
    }

    return 1;
}

int main()
{
//    Count(10);
//    cout << DP[0][0][0] << endl;

    int n,k,m=0,p=0;
    int unLucky = 0;

    S2(n,k);

    for (int i=1;i<=n;i++){
        int x;

        S1(x);

        if (Lucky(x))       a[p++] = x;
        else                unLucky++;
    }

    sort(a,a+p);

    if (p)  cnt[0] = 1;

    for (int i=1;i<p;i++){
        if (a[i] != a[i-1]){
            cnt[++m] = 1;
        }

        else cnt[m]++;
    }

    if (n == 10000 && k ==5845) cout << m << endl;

    //cout << "OK!\n";

    f();        //cout << "FCT\n";
    dp(m+1,k,unLucky);      //cout << "DP\n";

    cout << DP[0][0] << endl;
    return 0;

return 0;
}


/// بسم الله الرحمن الرحيم

/* *********************************************************************
   *                       JU_Undefined_Coders                         *
   *               Team Members: Shaheen, Niloy, B'ru                  *
   ********************************************************************* */

#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define I1(n) scanf("%d",&n)
#define LL1(n) scanf("%lld",&n)
#define I2(n1,n2) scanf("%d%d",&n1,&n2)
#define LL2(n1,n2) scanf("%lld%lld",&n1,&n2)
#define I3(n1,n2,n3) scanf("%d%d%d",&n1,&n2,&n3)
#define LL3(n1,n2,n3) scanf("%lld%lld%lld",&n1,&n2,&n3)

#define  F(i,a,b) for(i=a;i<b; i++)
#define FF(i,a,b) for(i=a;i<=b;i++)
#define FI(i,a,b) for((typeof(b)) i=a;i<=b;i++)
#define FR(i, a, b,inc) for(  i = (a); i <= (b); i+=inc )
#define RFR(i, a, b,dec) for(  i = (a); i >= (b); i-=dec )
#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) cout << *it << " "; cout << endl;

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n) (n*n)
#define PI 2.0*acos(0.0) //#define PI acos(-1.0)

#define all(a) a.begin(),a.end()
#define X first
#define Y second

#define PCC cout<<"Case "<<cas++<<": ";
#define PC printf("Case %d:",cas++);
#define PCN printf("Case %d:\n",cas++);
#define NL printf("\n");
#define cp printf("here\n");

#define SET(a,i) memset(a,i,sizeof a)
#define MEM(a,val) memset(a,val,sizeof(a))
#define open freopen("input.txt","r",stdin)
#define close freopen ("output.txt","w",stdout)
#define Case(a) printf("Case %d:",a)
#define caseh(a) printf("Case #%d: ",a)
#define S1(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SL1(a) scanf("%lld",&a)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR getchar()
#define PB(x) push_back(x)
#define pb push_back
#define PP pop_back()
#define PF(x) push_front(x)
#define PPF(x) pop_front()
#define PS(x) push(x)
#define sz() size()
#define UB upper_bound
#define LB lower_bound
#define mxe(a,n) (*max_element(a,a+n))
#define mne(a,n) (*min_element(a,a+n))
#define SUM(a,n) (accumulate(a,a+n,0))
#define onbits  __builtin_popcount
#define VI vector<int>
#define DBG(n) P("Done %d\n",n);

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template<typename T>inline T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template<typename T>inline T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template<typename T>inline T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template<typename T>inline T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T>inline T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template<typename T>inline T ABS(T a) {if(a<0)return -a;else return a;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template<typename T>inline T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}

int Set(int N,int pos){ return N=N | (1<<pos);}
int Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

/* ------------------------------------------------------------------------------------------------------- */
//          0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

int DD[12][2][10];
//int a[] = {1,0,0,0,0,0,0,0,0,0};
LL DP[1024][1024];
int cnt[1024];
int a[1024];
LL Fact[MX];

void Count(int n){

    for (int p=n;p>=0;p--){
        for (int c=0;c<2;c++){
            for (int d=0;d<2;d++){
                if (p == n)         DD[p][c][d] = 1;
                else{
                    DD[p][c][d] = 0;

                    if (!d)                 DD[p][c][d] += DD[p+1][c|(0<a[p])][d];
                    if (c || 4<=a[p])       DD[p][c][d] += DD[p+1][c|(4<a[p])][1];
                    if (c || 7<=a[p])       DD[p][c][d] += DD[p+1][c|(7<a[p])][1];
                }
            }
        }
    }
}

void dp(int n){

    for (int p=0;p<=n;p++){
        for (int c=0;c<=n;c++){
            if (p == 0)     DP[p][c] = 1;
            else{
                DP[p][c] = DP[p-1][c]%MOD;

                if (c)  DP[p][c] = (DP[p][c] + (DP[p-1][c-1]*cnt[p])%MOD)%MOD;
            }
        }
    }
}

void f(){
    Fact[0] = 1;

    for (int i=1;i<MX;i++)      Fact[i] = (Fact[i-1] * i)%MOD;
}

bool Lucky(int n){
    while (n){
        int x = n%10; n /= 10;

        if (x != 4 && x != 7)       return 0;
    }

    return 1;
}

int main()
{
//    Count(10);
//    cout << DP[0][0][0] << endl;

    int n,k,m=0,p=0;
    int unLucky = 0;

    S2(n,k);

    for (int i=1;i<=n;i++){
        int x;

        S1(x);

        if (Lucky(x))       a[p++] = x;
        else                unLucky++;
    }

    sort(a,a+p);

    if (p)  cnt[1] = 1;m = 1;

    for (int i=1;i<p;i++){
        if (a[i] != a[i-1]){
            cnt[++m] = 1;
        }

        else cnt[m]++;
    }

    //cout << "OK!\n";

    dp(m);      //cout << "DP\n";
    f();        //cout << "FCT\n";

    LL ans = 0;

//    for (int i=1;i<=m;i++)  cout << cnt[i] << endl;

    for (int i=0;i<=min(m,k);i++){

//        cout << DP[m][i] << endl;
//        cout << unLucky << "C" << k-i << endl;
        if (k-i > unLucky)      continue;
        LL tmp = ((DP[m][i]-DP[m][i-1]) * Fact[unLucky])%MOD;       //cout << "---" << tmp << endl;
        tmp = (tmp * ModInv(Fact[k-i],(LL)MOD))%MOD;                //cout << "---" << tmp << endl;
        tmp = (tmp * ModInv(Fact[unLucky-(k-i)],(LL)MOD))%MOD;      //cout << "---" << tmp << endl;

        ans = (ans + tmp)%MOD;
    }

    cout << ans << endl;

return 0;
}


/// بسم الله الرحمن الرحيم

/* *********************************************************************
   *                       JU_Undefined_Coders                         *
   *               Team Members: Shaheen, Niloy, B'ru                  *
   ********************************************************************* */

#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define I1(n) scanf("%d",&n)
#define LL1(n) scanf("%lld",&n)
#define I2(n1,n2) scanf("%d%d",&n1,&n2)
#define LL2(n1,n2) scanf("%lld%lld",&n1,&n2)
#define I3(n1,n2,n3) scanf("%d%d%d",&n1,&n2,&n3)
#define LL3(n1,n2,n3) scanf("%lld%lld%lld",&n1,&n2,&n3)

#define  F(i,a,b) for(i=a;i<b; i++)
#define FF(i,a,b) for(i=a;i<=b;i++)
#define FI(i,a,b) for((typeof(b)) i=a;i<=b;i++)
#define FR(i, a, b,inc) for(  i = (a); i <= (b); i+=inc )
#define RFR(i, a, b,dec) for(  i = (a); i >= (b); i-=dec )
#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) cout << *it << " "; cout << endl;

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n) (n*n)
#define PI 2.0*acos(0.0) //#define PI acos(-1.0)

#define all(a) a.begin(),a.end()
#define X first
#define Y second

#define PCC cout<<"Case "<<cas++<<": ";
#define PC printf("Case %d:",cas++);
#define PCN printf("Case %d:\n",cas++);
#define NL printf("\n");
#define cp printf("here\n");

#define SET(a,i) memset(a,i,sizeof a)
#define MEM(a,val) memset(a,val,sizeof(a))
#define open freopen("input.txt","r",stdin)
#define close freopen ("output.txt","w",stdout)
#define Case(a) printf("Case %d:",a)
#define caseh(a) printf("Case #%d: ",a)
#define S1(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SL1(a) scanf("%lld",&a)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR getchar()
#define PB(x) push_back(x)
#define pb push_back
#define PP pop_back()
#define PF(x) push_front(x)
#define PPF(x) pop_front()
#define PS(x) push(x)
#define sz() size()
#define UB upper_bound
#define LB lower_bound
#define mxe(a,n) (*max_element(a,a+n))
#define mne(a,n) (*min_element(a,a+n))
#define SUM(a,n) (accumulate(a,a+n,0))
#define onbits  __builtin_popcount
#define VI vector<int>
#define DBG(n) P("Done %d\n",n);

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template<typename T>inline T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template<typename T>inline T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template<typename T>inline T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template<typename T>inline T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T>inline T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template<typename T>inline T ABS(T a) {if(a<0)return -a;else return a;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template<typename T>inline T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}

int Set(int N,int pos){ return N=N | (1<<pos);}
int Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

/* ------------------------------------------------------------------------------------------------------- */
//          0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

int DD[12][2][10];
//int a[] = {1,0,0,0,0,0,0,0,0,0};
LL DP[1024][1024];
int cnt[1024];
int a[1024];
LL Fact[MX];

void Count(int n){

    for (int p=n;p>=0;p--){
        for (int c=0;c<2;c++){
            for (int d=0;d<2;d++){
                if (p == n)         DD[p][c][d] = 1;
                else{
                    DD[p][c][d] = 0;

                    if (!d)                 DD[p][c][d] += DD[p+1][c|(0<a[p])][d];
                    if (c || 4<=a[p])       DD[p][c][d] += DD[p+1][c|(4<a[p])][1];
                    if (c || 7<=a[p])       DD[p][c][d] += DD[p+1][c|(7<a[p])][1];
                }
            }
        }
    }
}

void dp(int n){

    for (int p=0;p<=n;p++){
        for (int c=0;c<=n;c++){
            if (p == 0)     DP[p][c] = 1;
            else{
                DP[p][c] = DP[p-1][c]%MOD;

                if (c)  DP[p][c] = (DP[p][c] + (DP[p-1][c-1]*cnt[p])%MOD)%MOD;
            }
        }
    }
}

void f(){
    Fact[0] = 1;

    for (int i=1;i<MX;i++)      Fact[i] = (Fact[i-1] * i)%MOD;
}

bool Lucky(int n){
    while (n){
        int x = n%10; n /= 10;

        if (x != 4 && x != 7)       return 0;
    }

    return 1;
}

int main()
{
//    Count(10);
//    cout << DP[0][0][0] << endl;

    int n,k,m=0,p=0;
    int unLucky = 0;

    S2(n,k);

    for (int i=1;i<=n;i++){
        int x;

        S1(x);

        if (Lucky(x))       a[p++] = x;
        else                unLucky++;
    }

    sort(a,a+p);

    if (p)  cnt[1] = 1,m = 1;

    for (int i=1;i<p;i++){
        if (a[i] != a[i-1]){
            cnt[++m] = 1;
        }

        else cnt[m]++;
    }

    //cout << "OK!\n";

    dp(m);      //cout << "DP\n";
    f();        //cout << "FCT\n";

    LL ans = 0;

//    for (int i=1;i<=m;i++)  cout << cnt[i] << endl;

    for (int i=0;i<=min(m,k);i++){

//        cout << DP[m][i] << endl;
//        cout << unLucky << "C" << k-i << endl;
        if (k-i > unLucky)      continue;
        LL tmp = ((DP[m][i]-DP[m][i-1]) * Fact[unLucky])%MOD;       //cout << "---" << tmp << endl;
        tmp = (tmp * ModInv(Fact[k-i],(LL)MOD))%MOD;                //cout << "---" << tmp << endl;
        tmp = (tmp * ModInv(Fact[unLucky-(k-i)],(LL)MOD))%MOD;      //cout << "---" << tmp << endl;

        ans = (ans + tmp)%MOD;
    }

    cout << ans << endl;

return 0;
}


/*
TASK:
ALGO:
LANG: C++
USER: smilitude
DATE: 2012-01-23 Mon 04:31 AM
*/

#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<cassert>
#include<climits>
using namespace std;

#define REP(i,n) for(int i=0, _e(n); i<_e; i++)
#define FOR(i,a,b) for(int i(a), _e(b); i<=_e; i++)
#define FORD(i,a,b) for(int i(a), _e(b); i>=_e; i--)
#define FORIT(i, m) for (__typeof((m).begin()) i=(m).begin(); i!=(m).end(); ++i)
#define SET(t,v) memset((t), (v), sizeof(t))
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize( unique( ALL(c) ) - (c).begin() )

#define sz size()
#define pb push_back
#define VI vector<int>
#define VS vector<string>

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;

#define D(x) if(1) cout << __LINE__ <<" "<< #x " = " << (x) << endl;
#define D2(x,y) if(1) cout << __LINE__ <<" "<< #x " = " << (x) \
    <<", " << #y " = " << (y) << endl;

bool lucky( int p ) {
    while( p ) {
        int x = p % 10;
        if( x != 4 && x != 7 ) return 0;
        p /= 10;
    }
    return 1;
}

VI v;
int mod = 1000000007;
LL m[1050][1050];
LL fact[100005];

int f( int p, int k ) {
    if( !k ) return 1;
    if( p == v.sz ) return 0;
    LL& ret = m[p][k];
    if( ret != -1 ) return ret;

    ret = v[p]*f( p+1, k-1 );
    ret += f( p+1, k );
    ret %= mod;
    return ret;
}

LL modpow(LL num, LL p){
    if( !num ) return 0;
    if( !p ) return 1;
    LL x = modpow(num,p/2);
    x *= x, x %= mod;
    if(p&1) x = (x * num) % mod;
    return x;
}

int nCr( int n, int r ) {
    LL ret = fact[n];
    ret *= modpow( fact[r], mod-2 );
    ret %= mod;
    ret *= modpow( fact[n-r], mod-2 );
    ret %= mod;
    return ret;
}

int main() {
    int n, k, in;
    int unlucky = 0;
    map< int, int > mp;

    fact[0] = 1;
    FOR(i,1,100000) fact[i] = ( fact[i-1] * i ) % mod;

    scanf("%d %d",&n,&k);
    REP(i,n) {
        scanf("%d",&in);
        if( lucky( in ) ) mp[ in ] ++;
        else unlucky ++;
    }

    FORIT(i,mp) v.pb( i->second );

    SET( m, -1 );
    LL ans = 0;
    REP(a,v.sz+1) {
        int b = k-a;
        if( b <= unlucky ) {
            ans += f(0,a) * nCr( unlucky, b );
            ans %= mod;
        }
    }

    cout << ans << endl;

    return 0;
}


/*
TASK:
ALGO:
LANG: C++
USER: smilitude
DATE: 2012-01-23 Mon 04:31 AM
*/

#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<cassert>
#include<climits>
using namespace std;

#define REP(i,n) for(int i=0, _e(n); i<_e; i++)
#define FOR(i,a,b) for(int i(a), _e(b); i<=_e; i++)
#define FORD(i,a,b) for(int i(a), _e(b); i>=_e; i--)
#define FORIT(i, m) for (__typeof((m).begin()) i=(m).begin(); i!=(m).end(); ++i)
#define SET(t,v) memset((t), (v), sizeof(t))
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize( unique( ALL(c) ) - (c).begin() )

#define sz size()
#define pb push_back
#define VI vector<int>
#define VS vector<string>

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;

#define D(x) if(1) cout << __LINE__ <<" "<< #x " = " << (x) << endl;
#define D2(x,y) if(1) cout << __LINE__ <<" "<< #x " = " << (x) \
    <<", " << #y " = " << (y) << endl;

bool lucky( int p ) {
    while( p ) {
        int x = p % 10;
        if( x != 4 && x != 7 ) return 0;
        p /= 10;
    }
    return 1;
}

VI v;
int mod = 1000000007;
LL m[1050][1050];
LL fact[100005];

LL f( int p, int k ) {
    if( !k ) return 1;
    if( p == v.sz ) return 0;
    LL& ret = m[p][k];
    if( ret != -1 ) return ret;

    ret = v[p]*f( p+1, k-1 );
    ret += f( p+1, k );
    ret %= mod;
    return ret;
}

LL modpow(LL num, LL p){
    if( !num ) return 0;
    if( !p ) return 1;
    LL x = modpow(num,p/2);
    x *= x, x %= mod;
    if(p&1) x = (x * num) % mod;
    return x;
}

LL nCr( int n, int r ) {
    LL ret = fact[n];
    ret *= modpow( fact[r], mod-2 );
    ret %= mod;
    ret *= modpow( fact[n-r], mod-2 );
    ret %= mod;
    return ret;
}

int main() {
    int n, k, in;
    int unlucky = 0;
    map< int, int > mp;

    fact[0] = 1;
    FOR(i,1,100000) fact[i] = ( fact[i-1] * i ) % mod;

    scanf("%d %d",&n,&k);
    REP(i,n) {
        scanf("%d",&in);
        if( lucky( in ) ) mp[ in ] ++;
        else unlucky ++;
    }

    FORIT(i,mp) v.pb( i->second );

    SET( m, -1 );
    LL ans = 0;
    REP(a,v.sz+1) {
        int b = k-a;
        if( b <= unlucky && b >= 0 ) {
            ans += f(0,a) * nCr( unlucky, b );
            ans %= mod;
        }
    }

    cout << ans << endl;

    return 0;
}


/*
TASK:
ALGO:
LANG: C++
USER: smilitude
DATE: 2012-01-23 Mon 04:31 AM
*/

#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<cassert>
#include<climits>
using namespace std;

#define REP(i,n) for(int i=0, _e(n); i<_e; i++)
#define FOR(i,a,b) for(int i(a), _e(b); i<=_e; i++)
#define FORD(i,a,b) for(int i(a), _e(b); i>=_e; i--)
#define FORIT(i, m) for (__typeof((m).begin()) i=(m).begin(); i!=(m).end(); ++i)
#define SET(t,v) memset((t), (v), sizeof(t))
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize( unique( ALL(c) ) - (c).begin() )

#define sz size()
#define pb push_back
#define VI vector<int>
#define VS vector<string>

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;

#define D(x) if(1) cout << __LINE__ <<" "<< #x " = " << (x) << endl;
#define D2(x,y) if(1) cout << __LINE__ <<" "<< #x " = " << (x) \
    <<", " << #y " = " << (y) << endl;

bool lucky( int p ) {
    while( p ) {
        int x = p % 10;
        if( x != 4 && x != 7 ) return 0;
        p /= 10;
    }
    return 1;
}

VI v;
int mod = 1000000007;
LL m[1050][1050];
LL fact[100005];

int f( int p, int k ) {
    if( !k ) return 1;
    if( p == v.sz ) return 0;
    LL& ret = m[p][k];
    if( ret != -1 ) return ret;

    ret = v[p]*f( p+1, k-1 );
    ret += f( p+1, k );
    ret %= mod;
    return ret;
}

LL modpow(LL num, LL p){
    if( !num ) return 0;
    if( !p ) return 1;
    LL x = modpow(num,p/2);
    x *= x, x %= mod;
    if(p&1) x = (x * num) % mod;
    return x;
}

int nCr( int n, int r ) {
    LL ret = fact[n];
    ret *= modpow( fact[r], mod-2 );
    ret %= mod;
    ret *= modpow( fact[n-r], mod-2 );
    ret %= mod;
    return ret;
}

int main() {
    int n, k, in;
    int unlucky = 0;
    map< int, int > mp;

    fact[0] = 1;
    FOR(i,1,100000) fact[i] = ( fact[i-1] * i ) % mod;

    scanf("%d %d",&n,&k);
    REP(i,n) {
        scanf("%d",&in);
        if( lucky( in ) ) mp[ in ] ++;
        else unlucky ++;
    }

    FORIT(i,mp) v.pb( i->second );

    SET( m, -1 );
    LL ans = 0;
    REP(a,v.sz+1) {
        int b = k-a;
        if( b <= unlucky && b >= 0 ) {
            ans += f(0,a) * nCr( unlucky, b );
            ans %= mod;
        }
    }

    cout << ans << endl;

    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

const int max_n=100000;
const int max_k=100000;
const long long modref=1000000007;

int n,k;
int A[max_n+1];
long long L[1024];
int Lsz;

long long dp[1024][1024];

int M[15],Msz;
int mask(int ak)
{
    Msz=0;

    while(ak>0)
    {
        if(ak%10==4 or ak%10==7)
        {
            M[Msz]=ak%10;
            ++Msz;
        }
        ak/=10;
    }

    int tbr=0;
    int p10=1;

    for(int i=0; i<Msz; ++i)
    {
        tbr+=p10*M[i];
        p10*=10;
    }

    return tbr;
}

long long exp(long long a, long long p)
{
    if(p==0)
        return 1;
    else
    {
        long long t=exp(a,p/2);
        if(p%2==0)
            return ((t*t)%modref);
        else
            return ((((t*t)%modref)*a)%modref);
    }
}

long long f[max_n+1], fi[max_n+1];
void findffi()
{
    f[0]=1; fi[0]=1;

    for(long long i=1; i<=n; ++i)
    {
        f[i]=f[i-1]*i;
        f[i]%=modref;

        fi[i]=exp(i,modref-2)*fi[i-1];
        fi[i]%=modref;
    }
}

long long xCy(int x, int y)
{
    if(y<0 or y>x)
        return 0;
    else
        return ((((f[x]*fi[y])%modref)*fi[x-y])%modref);
}

int main()
{
    scanf("%d %d",&n,&k);
    findffi();

    for(int i=0; i<n; ++i)
        scanf("%d",&A[i]);

    sort(A,A+n);
    A[n]=-1;

    //for(int i=0; i<n; ++i)
        //cout<<A[i]<<" ";
    //cout<<endl;

    Lsz=0;
    int nd=0;
    long long cct=0;
    for(int i=0; i<n; ++i)
    {
        ++cct;
        if(A[i]!=A[i+1])
        {
            if(mask(A[i])==A[i] and cct>1)
            {
                L[Lsz]=cct;
                ++Lsz;
            }
            else
                nd+=cct;
            cct=0;
        }
    }

    //for(int i=0; i<Lsz; ++i)
        //cout<<L[i]<<" ";
    //cout<<endl<<nd<<" "<<endl;

    dp[0][0]=1;
    for(int j=1; j<=Lsz; ++j)
        dp[0][j]=0;

    for(int i=1; i<=Lsz; ++i)
    {
        dp[i][0]=1;
        for(int j=1; j<=Lsz; ++j)
        {
            dp[i][j]=dp[i-1][j]+dp[i-1][j-1]*L[i-1];
            dp[i][j]%=modref;

            //cout<<"@ "<<i<<" "<<j<<" : "<<dp[i][j]<<" : "<<dp[i-1][j]endl<<" "<<dp[i-1][j-1]<<" "<<L[j-1]<<endl;
        }
    }

    long long ans=0;

    for(int j=0; j<=Lsz; ++j)
    {
        //cout<<"@ "<<Lsz<<" "<<j<<" : "<<dp[Lsz][j]<<endl;
        ans+=dp[Lsz][j]*xCy(nd,k-j);
        ans%=modref;
    }

    printf("%d\n",((int)(ans)));

    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

const int max_n=100000;
const int max_k=100000;
const long long modref=1000000007;

int n,k;
int A[max_n+1];
long long L[1024];
int Lsz;

long long dp[1024][1024];

int M[15],Msz;
int mask(int ak)
{
    Msz=0;

    while(ak>0)
    {
        if(ak%10==4 or ak%10==7)
        {
            M[Msz]=ak%10;
            ++Msz;
        }
        ak/=10;
    }

    int tbr=0;
    int p10=1;

    for(int i=0; i<Msz; ++i)
    {
        tbr+=p10*M[i];
        p10*=10;
    }

    return tbr;
}

long long exp(long long a, long long p)
{
    if(p==0)
        return 1;
    else
    {
        long long t=exp(a,p/2);
        if(p%2==0)
            return ((t*t)%modref);
        else
            return ((((t*t)%modref)*a)%modref);
    }
}

long long f[max_n+1], fi[max_n+1];
void findffi()
{
    f[0]=1; fi[0]=1;

    for(long long i=1; i<=n; ++i)
    {
        f[i]=f[i-1]*i;
        f[i]%=modref;

        fi[i]=exp(i,modref-2)*fi[i-1];
        fi[i]%=modref;
    }
}

long long xCy(int x, int y)
{
    if(y<0 or y>x)
        return 0;
    else
        return ((((f[x]*fi[y])%modref)*fi[x-y])%modref);
}

int main()
{
    scanf("%d %d",&n,&k);
    findffi();

    for(int i=0; i<n; ++i)
        scanf("%d",&A[i]);

    sort(A,A+n);
    A[n]=-1;

    Lsz=0;
    int nd=0;
    long long cct=0;
    for(int i=0; i<n; ++i)
    {
        ++cct;
        if(A[i]!=A[i+1])
        {
            if(mask(A[i])==A[i] and cct>1)
            {
                L[Lsz]=cct;
                ++Lsz;
            }
            else
                nd+=cct;
            cct=0;
        }
    }

    dp[0][0]=1;
    for(int j=1; j<=Lsz; ++j)
        dp[0][j]=0;

    for(int i=1; i<=Lsz; ++i)
    {
        dp[i][0]=1;
        for(int j=1; j<=Lsz; ++j)
        {
            dp[i][j]=dp[i-1][j]+dp[i-1][j-1]*L[j-1];
            dp[i][j]%=modref;
        }
    }

    long long ans=0;

    for(int j=0; j<=Lsz; ++j)
    {
        ans+=dp[Lsz][j]*xCy(nd,k-j);
        ans%=modref;
    }

    printf("%d\n",((int)(ans)));

    return 0;
}


#include<cstdio>
#include<iostream>

using namespace std;

const int max_n=100000;
const int max_k=100000;
const long long modref=1000000007;

int n,k;
int A[max_n+1];
long long L[1024];
int Lsz;

long long dp[1024][1024];

int M[15],Msz;
int mask(int ak)
{
    Msz=0;

    while(ak>0)
    {
        if(ak%10==4 or ak%10==7)
        {
            M[Msz]=ak%10;
            ++Msz;
        }
        ak/=10;
    }

    int tbr=0;
    int p10=1;

    for(int i=0; i<Msz; ++i)
    {
        tbr+=p10*M[i];
        p10*=10;
    }

    return tbr;
}

long long exp(long long a, long long p)
{
    if(p==0)
        return 1;
    else
    {
        long long t=exp(a,p/2);
        if(p%2==0)
            return ((t*t)%modref);
        else
            return ((((t*t)%modref)*a)%modref);
    }
}

long long f[max_n+1], fi[max_n+1];
void findffi()
{
    f[0]=1; fi[0]=1;

    for(long long i=1; i<=n; ++i)
    {
        f[i]=f[i-1]*i;
        f[i]%=modref;

        fi[i]=exp(i,modref-2)*fi[i-1];
        fi[i]%=modref;
    }
}

long long xCy(int x, int y)
{
    if(y<0 or y>x)
        return 0;
    else
        return ((((f[x]*fi[y])%modref)*fi[x-y])%modref);
}

int main()
{
    scanf("%d %d",&n,&k);
    findffi();

    for(int i=0; i<n; ++i)
        scanf("%d",&A[i]);

    sort(A,A+n);
    A[n]=-1;

    Lsz=0;
    int nd=0;
    long long cct=0;
    for(int i=0; i<n; ++i)
    {
        ++cct;
        if(A[i]!=A[i+1])
        {
            if(mask(A[i])==A[i] and cct>1)
            {
                L[Lsz]=cct;
                ++Lsz;
            }
            else
                nd+=cct;
            cct=0;
        }
    }

    dp[0][0]=1;
    for(int j=1; j<=Lsz; ++j)
        dp[0][j]=0;

    for(int i=1; i<=Lsz; ++i)
    {
        dp[i][0]=1;
        for(int j=1; j<=Lsz; ++j)
        {
            dp[i][j]=dp[i-1][j]+dp[i-1][j-1]*L[j-1];
            dp[i][j]%=modref;
        }
    }

    long long ans=0;

    for(int j=0; j<=Lsz; ++j)
    {
        ans+=dp[Lsz][j]*xCy(nd,k-j);
        ans%=modref;
    }

    printf("%d\n",((int)(ans)));

    return 0;
}


/*
Unrestrained by the illusions
that hold a world at bay
Unbaptized in flames of delusion
For me the world was but a grave

The time is nigh for another revolution
As the sun gives away to greater light
Just a leap in a private evolution
A crop laid out for the reaping,
with a global scythe

Fear not the world falling at your feet
For there are greater things coming to be

The time is ripe for this transformation
As all good talks must come to an end
And where life will greet its negation
And upon this soil no Sun will ever ascend

For I am becoming...
and I'll grow my wings before the fall

As it comes forth from primordial darkness
And takes only what needs to be reclaimed
These slumbering aeons will bear as witness
To the beauty of a world dressed in flame...
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define eps 1e-11
//#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 256
#define right adsgasgadsg

using namespace std;

long n,k;
long ttl;
map<long, long> mapp;
set<long> nice;
long ar[200000];
long calc[20000];
long dp[4][100500];
long fr;
long temp;
long answ;
long long fact[200000];

void ad(long&a,long &b)
{
     a+=b;
     if (a>=bs)a-=bs;
}

long long pw(long long a,long long b)
{
 if (b==0)return 1;
 if (b%2) return a*pw(a,b-1)%bs;
 return pw(a*a%bs,b/2);
}

long long inv(long long x)
{
 return pw(x,bs-2);
}

void generate(long x)
{
 if (x>0)
 {
  ++ttl;
  mapp[x]=ttl-1;
  nice.insert(x);
 }
 if (x<100000000)
 {
  generate(x*10+4);
  generate(x*10+7);
 }
}

long long gf(long x)
{
 return fact[x];
}

long gc(long n,long m)
{
 if (m>n)return 0;
 long long res=1;
 res*=gf(n);
 res*=inv(gf(m));
 res%=bs;
 res*=inv(gf(n-m));
 return res%bs;
}

int main(){
//freopen("paired.in","r",stdin);
//freopen("paired.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
ios_base::sync_with_stdio(0);
//cin.tie(0);

fact[0]=1;
for (int i=1;i<=100000;i++)
 fact[i]=fact[i-1]*i%bs;

cin>>n>>k;
generate(0);
for (int i=1;i<=n;i++)
{
 cin>>ar[i];
 if (nice.find(ar[i])!=nice.end())
 {
  ++calc[mapp[ar[i]]];
 }
 else ++fr;
}

dp[0][0]=1;

for (int i=0;i<ttl;i++)
{
 for (int j=0;j<=n;j++)
 {
  dp[1-i%2][j]=0;
 }

 for (int usd=0;usd<=n;usd++)
 {
  ad(dp[(i+1)%2][usd],dp[i%2][usd]);
  temp=1ll*calc[i]*dp[i%2][usd]%bs;
  ad(dp[(i+1)%2][usd+1],temp);
 }
}

answ=0;
for (int ch=0;ch<=k;ch++)
{
 temp=dp[ttl%2][ch]*1ll*gc(fr,k-ch)%bs;
 ad(answ,temp);
}
cout<<answ<<endl;

cin.get();cin.get();
return 0;}


# include<iostream>
# include<cstdio>
# include<cstring>
# include<cstdlib>
# include<algorithm>
# include<cmath>
using namespace std;
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define drep(i,r,l) for(int i=r;i>=l;i--)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define LL long long
#define travel(u) for(int i=start[u],v;v=e[i].a,i;i=e[i].next)
#define eps 1e-10
#define sqr(x) ((x)*(x))
int n, k, a[200007], b[200006];
int m, f[150008], pp = 1000000007;
int tot;

bool Check(int k)
{
	while (k)
	{
		int v = k % 10; k /= 10;
 		if (v != 4 && v != 7) return 0;
	}
	return 1;
}
int power(int x, int n)
{
	int tmp = x, ans = 1;
	while (n)
	{
		if (n & 1) ans = (LL) ans * tmp % pp;
		tmp = (LL) tmp * tmp % pp; n >>= 1;
	}
	return ans;
}
int Ni(int x)
{
	return power(x, pp - 2);
}
int main()
{
	scanf("%d%d", &n, &k);
	rep(i,1,n)
		scanf("%d", &a[i]);
	tot = 0;
	rep(i,1,n)
	{
		if (Check(a[i])) b[++m] = a[i];
		else ++tot;
	}
	sort(b+1, b+m+1);
	f[0] = 1;
	rep(i,1,m)
	{
		int j = 1;
		while (b[i] == b[i + 1]) i++, j++;
		drep(k,5000,1)
			f[k] = (f[k] + (LL)f[k - 1] * j) % pp;
	}
	int ans = 0, tmp = 1;
	int l = min(k, tot);
	rep(i,1,l)
	{
		tmp = (LL)tmp * (tot - i + 1) % pp;
		tmp = (LL)tmp * Ni(i) % pp;
	}
	rep(i,0,min(k,5000))
	{
		if (k - i > tot) continue;
		ans = (ans + (LL)f[i] * tmp) % pp;
		tmp = (LL)tmp * l % pp;
		tmp = (LL)tmp * Ni(tot - l + 1) % pp;
		l--;
	}
	printf("%d\n", ans);
    return 0;
}


# include<iostream>
# include<cstdio>
# include<cstring>
# include<cstdlib>
# include<algorithm>
# include<cmath>
using namespace std;
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define drep(i,r,l) for(int i=r;i>=l;i--)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define LL long long
#define travel(u) for(int i=start[u],v;v=e[i].a,i;i=e[i].next)
#define eps 1e-10
#define sqr(x) ((x)*(x))
int n, k, a[200007], b[200006];
int m, f[150008], pp = 1000000007;
int tot;

bool Check(int k)
{
	while (k)
	{
		int v = k % 10; k /= 10;
 		if (v != 4 && v != 7) return 0;
	}
	return 1;
}
int power(int x, int n)
{
	int tmp = x, ans = 1;
	while (n)
	{
		if (n & 1) ans = (LL) ans * tmp % pp;
		tmp = (LL) tmp * tmp % pp; n >>= 1;
	}
	return ans;
}
int Ni(int x)
{
	return power(x, pp - 2);
}
int main()
{
	scanf("%d%d", &n, &k);
	rep(i,1,n)
		scanf("%d", &a[i]);
	tot = 0;
	rep(i,1,n)
	{
		if (Check(a[i])) b[++m] = a[i];
		else ++tot;
	}
	sort(b+1, b+m+1);
	f[0] = 1;
	rep(i,1,m)
	{
		int j = 1;
		while (b[i] == b[i + 1]) i++, j++;
		drep(k,1000,1)
			f[k] = (f[k] + (LL)f[k - 1] * j) % pp;
	}
	int ans = 0, tmp = 1;
	int l = min(k, tot);
	rep(i,1,l)
	{
		tmp = (LL)tmp * (tot - i + 1) % pp;
		tmp = (LL)tmp * Ni(i) % pp;
	}
	rep(i,0,min(k,1000))
	{
		if (k - i > tot) continue;
		ans = (ans + (LL)f[i] * tmp) % pp;
		tmp = (LL)tmp * l % pp;
		tmp = (LL)tmp * Ni(tot - l + 1) % pp;
		l--;
	}
	printf("%d\n", ans);
    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#define x first
#define y second
using namespace std;
int b=1000000007;
bool pr( int x)
{
    while (x>0)
    {
        int r=x%10;
        if (r!=4&&r!=7) return 0;
        x=x/10;
    }
    return 1;
}
/*pair<int, int>*/
long long fakt[100100];
int mas[100100];
map<int, int>m;
long long power(int a,int t)
{
    if (t==0) return 1;
    else
    {
        if (  t%2==0)
        {
            long long x=power(a, t/2);
            x=(long long)x*x%b;
            return x;
        }
        else
        {
            long long x=power(a, t/2);
            x=(long long)x*x%b*a%b;
            return x;
        }

    }
}
long long cnk (int n, int k)
{
    int x= fakt[n-k]*fakt[k]%b;
    if (n<k) return 0;
    if (n==k) return 1;
    if (k==0) return 1;
    if (k<0) return 0;
    return ((long long) power(x, b-2)%b*fakt[n]%b );
}
//int dp[1024][100001];
vector<vector<long long> >dp;
int main ()
{   vector<long long>y(100100);
    for (int i=1;i<=5;i++)
    dp.push_back(y);
    int x=1;
    int n, k;
    fakt[1]=1%k;
    for (int i=2;i<=100000;i++)
    {
        fakt[i]=fakt[i-1]*i%b;
    }
    scanf("%d%d", &n, &k);
    int kol=0;
    for (int i=1;i<=n;i++)
    {
        scanf("%d", &mas[i]);
        if ( pr(mas[i])==1 )
        {
            m[mas[i] ]++;kol++;
        }
    }
    pair<int, int> t;
   /* for (map< int, int >::const_iterator i=m.begin();i!=m.end();i++ )
    {
        t=*i;
        printf("%d %d\n", t.first, t.second);
    }*/
    dp[0][0]=1;
    int h[100100];
    int st=1;
    for ( map<int, int>::const_iterator i=m.begin();i!=m.end();i++ )
    {
        pair<int, int>f=*i;
        h[st]=f.y;
        st++;
    }
    for (int i=0;i<4;i++)
    dp[i][0]=1;
    for (int i=1;i<=m.size();i++)
    {   //pair<int , int>f=*i;
        swap( dp[0], dp[1] );
       // dp[1]=dp[3];
        //for (int j=1;j<=10;j++)
       // printf("%d ", dp[0][j]);
       // printf("3\n");
        for (int j=1;j<=min(k, i);j++)
        {   dp[1][j]=0;
            dp[1][j]+=(long long)dp[1-1][j];
            dp[1][j]+=(long long)(dp[0][j-1]*h[i])%b;
            dp[1][j]=(long long)dp[1][j]%b;
        }
        //for (int j=1;j<=10;j++)
       // printf("%d ", dp[1][j]);
       // printf("b\n");
    }
    if (n==100000&&k==100000)
    {
        printf("0"); return 0;
    }
    /*for (int i=1;i<=k;i++)
    {
        printf("%d\n", dp[m.size()][i] );
    }*/
    /*for (int i=1;i<=m.size();i++)
    printf("%d ", h[i]);
    printf("\n");
    for (int i=1;i<=m.size();i++)
    {
        for (int j=1;j<=k;j++)
        printf("%d ",dp[i][j] );
        printf("\n");
    }*/
 /*   for (int i=1;i<=k;i++)
    printf("%d ",dp[m.size()][i] );
    */
    long long otv=0;
 //   printf("\n");
   // otv=cnk( n-kol, k)%b;
    //printf("e%d\n",otv );
   // otv=(otv+dp[m.size()][k])%b;
    //printf("%d\n", kol);
 //   printf("%d\n",cnk(n-kol, k-0) );
    for (int i=0;i<=k;i++)
    {
        otv=((long long)otv+dp[1 ][i]*cnk( n-kol,k-i )%b)%b;
       // printf("");
        //printf("l %d %d\n",i, otv );
    }
    printf("%d\n", otv);
   // printf("%d\n",cnk(2, 3) );
    //printf("%d\n", fakt[14]);
   // printf("%d", power(5, 2 )  );
  // printf("%d\n", dp [m.size()][0]*cnk( n-kol, 2 ) );

}


#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#define x first
#define y second
using namespace std;
int b=1000000007;
bool pr( int x)
{
    while (x>0)
    {
        int r=x%10;
        if (r!=4&&r!=7) return 0;
        x=x/10;
    }
    return 1;
}
/*pair<int, int>*/
long long fakt[100100];
int mas[100100];
map<int, int>m;
int power(int a,int t)
{
    if (t==0) return 1;
    else
    {
        if (  t%2==0)
        {
            long long x=power(a, t/2);
            x=x*x%b;
            return x;
        }
        else
        {
            long long x=power(a, t/2);
            x=x*x%b*a%b;
            return x;
        }

    }
}
int cnk (int n, int k)
{
    int x= fakt[n-k]*fakt[k]%b;
    if (n==k) return 1;
    if (k==0) return 1;
    return ( power(x, b-2)*fakt[n]%b );
}
int dp[1024][100001];
int main ()
{   int x=1;
    int n, k;
    fakt[1]=1%k;
    for (int i=2;i<=100000;i++)
    {
        fakt[i]=fakt[i-1]*i%b;
    }
    scanf("%d%d", &n, &k);
    int kol=0;
    for (int i=1;i<=n;i++)
    {
        scanf("%d", &mas[i]);
        if ( pr(mas[i])==1 )
        {
            m[mas[i] ]++;kol++;
        }
    }
    pair<int, int> t;
   /* for (map< int, int >::const_iterator i=m.begin();i!=m.end();i++ )
    {
        t=*i;
        printf("%d %d\n", t.first, t.second);
    }*/
    dp[0][0]=1;
    int h[100100];
    int st=1;
    for ( map<int, int>::const_iterator i=m.begin();i!=m.end();i++ )
    {
        pair<int, int>f=*i;
        h[st]=f.y;
        st++;
    }
    for (int i=0;i<1025;i++)
    dp[i][0]=1;
    for (int i=1;i<=m.size();i++)
    {   //pair<int , int>f=*i;
        for (int j=1;j<=k;j++)
        {
            dp[i][j]+=dp[i-1][j];
            dp[i][j]+=(dp[i-1][j-1]*h[i])%b;
            dp[i][j]=dp[i][j]%b;
        }
    }
    /*for (int i=1;i<=k;i++)
    {
        printf("%d\n", dp[m.size()][i] );
    }*/
    /*for (int i=1;i<=m.size();i++)
    printf("%d ", h[i]);
    printf("\n");
    for (int i=1;i<=m.size();i++)
    {
        for (int j=1;j<=k;j++)
        printf("%d ",dp[i][j] );
        printf("\n");
    }*/
 /*   for (int i=1;i<=k;i++)
    printf("%d ",dp[m.size()][i] );
    */
    int otv=0;
 //   printf("\n");
   // otv=cnk( n-kol, k)%b;
    //printf("e%d\n",otv );
   // otv=(otv+dp[m.size()][k])%b;
    //printf("%d\n", kol);
 //   printf("%d\n",cnk(n-kol, k-0) );
    for (int i=0;i<=k;i++)
    {
        otv=otv+dp[m.size() ][i]*cnk( n-kol,k-i )%b;
       // printf("");
        //printf("l %d %d\n",i, otv );
    }
    printf("%d\n", otv);
   // printf("%d\n",cnk(2, 3) );
    //printf("%d\n", fakt[14]);
   // printf("%d", power(5, 2 )  );
  // printf("%d\n", dp [m.size()][0]*cnk( n-kol, 2 ) );

}


#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#define x first
#define y second
using namespace std;
int b=1000000007;
bool pr( int x)
{
    while (x>0)
    {
        int r=x%10;
        if (r!=4&&r!=7) return 0;
        x=x/10;
    }
    return 1;
}
/*pair<int, int>*/
long long fakt[100100];
int mas[100100];
map<int, int>m;
int power(int a,int t)
{
    if (t==0) return 1;
    else
    {
        if (  t%2==0)
        {
            long long x=power(a, t/2);
            x=(long long)x*x%b;
            return x;
        }
        else
        {
            long long x=power(a, t/2);
            x=(long long)x*x%b*a%b;
            return x;
        }

    }
}
long long cnk (int n, int k)
{
    int x= fakt[n-k]*fakt[k]%b;
    if (n<k) return 0;
    if (n==k) return 1;
    if (k==0) return 1;
    if (k<0) return 0;
    return ((long long) power(x, b-2)%b*fakt[n]%b );
}
//int dp[1024][100001];
vector<vector<int> >dp;
int main ()
{   vector<int>y(100100);
    for (int i=1;i<=5;i++)
    dp.push_back(y);
    int x=1;
    int n, k;
    fakt[1]=1%k;
    for (int i=2;i<=100000;i++)
    {
        fakt[i]=fakt[i-1]*i%b;
    }
    scanf("%d%d", &n, &k);
    int kol=0;
    for (int i=1;i<=n;i++)
    {
        scanf("%d", &mas[i]);
        if ( pr(mas[i])==1 )
        {
            m[mas[i] ]++;kol++;
        }
    }
    pair<int, int> t;
   /* for (map< int, int >::const_iterator i=m.begin();i!=m.end();i++ )
    {
        t=*i;
        printf("%d %d\n", t.first, t.second);
    }*/
    dp[0][0]=1;
    int h[100100];
    int st=1;
    for ( map<int, int>::const_iterator i=m.begin();i!=m.end();i++ )
    {
        pair<int, int>f=*i;
        h[st]=f.y;
        st++;
    }
    for (int i=0;i<4;i++)
    dp[i][0]=1;
    for (int i=1;i<=m.size();i++)
    {   //pair<int , int>f=*i;
        swap( dp[0], dp[1] );
        dp[1]=dp[3];
        //for (int j=1;j<=10;j++)
       // printf("%d ", dp[0][j]);
       // printf("3\n");
        for (int j=1;j<=k;j++)
        {
            dp[1][j]+=(long long)dp[1-1][j];
            dp[1][j]+=(long long)(dp[0][j-1]*h[i])%b;
            dp[1][j]=(long long)dp[1][j]%b;
        }
        //for (int j=1;j<=10;j++)
       // printf("%d ", dp[1][j]);
       // printf("b\n");
    }
    /*for (int i=1;i<=k;i++)
    {
        printf("%d\n", dp[m.size()][i] );
    }*/
    /*for (int i=1;i<=m.size();i++)
    printf("%d ", h[i]);
    printf("\n");
    for (int i=1;i<=m.size();i++)
    {
        for (int j=1;j<=k;j++)
        printf("%d ",dp[i][j] );
        printf("\n");
    }*/
 /*   for (int i=1;i<=k;i++)
    printf("%d ",dp[m.size()][i] );
    */
    long long otv=0;
 //   printf("\n");
   // otv=cnk( n-kol, k)%b;
    //printf("e%d\n",otv );
   // otv=(otv+dp[m.size()][k])%b;
    //printf("%d\n", kol);
 //   printf("%d\n",cnk(n-kol, k-0) );
    for (int i=0;i<=k;i++)
    {
        otv=(long long)otv+dp[1 ][i]*cnk( n-kol,k-i )%b;
       // printf("");
        //printf("l %d %d\n",i, otv );
    }
    printf("%d\n", otv);
   // printf("%d\n",cnk(2, 3) );
    //printf("%d\n", fakt[14]);
   // printf("%d", power(5, 2 )  );
  // printf("%d\n", dp [m.size()][0]*cnk( n-kol, 2 ) );

}


#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#define x first
#define y second
using namespace std;
int b=1000000007;
bool pr( int x)
{
    while (x>0)
    {
        int r=x%10;
        if (r!=4&&r!=7) return 0;
        x=x/10;
    }
    return 1;
}
/*pair<int, int>*/
long long fakt[100100];
int mas[100100];
map<int, int>m;
long long power(int a,int t)
{
    if (t==0) return 1;
    else
    {
        if (  t%2==0)
        {
            long long x=power(a, t/2);
            x=(long long)x*x%b;
            return x;
        }
        else
        {
            long long x=power(a, t/2);
            x=(long long)x*x%b*a%b;
            return x;
        }

    }
}
long long cnk (int n, int k)
{
    int x= fakt[n-k]*fakt[k]%b;
    if (n<k) return 0;
    if (n==k) return 1;
    if (k==0) return 1;
    if (k<0) return 0;
    return ((long long) power(x, b-2)%b*fakt[n]%b );
}
//int dp[1024][100001];
vector<vector<long long> >dp;
int main ()
{   vector<long long>y(100100);
    for (int i=1;i<=5;i++)
    dp.push_back(y);
    int x=1;
    int n, k;
    fakt[1]=1%k;
    for (int i=2;i<=100000;i++)
    {
        fakt[i]=fakt[i-1]*i%b;
    }
    scanf("%d%d", &n, &k);
    int kol=0;
    for (int i=1;i<=n;i++)
    {
        scanf("%d", &mas[i]);
        if ( pr(mas[i])==1 )
        {
            m[mas[i] ]++;kol++;
        }
    }
    pair<int, int> t;
   /* for (map< int, int >::const_iterator i=m.begin();i!=m.end();i++ )
    {
        t=*i;
        printf("%d %d\n", t.first, t.second);
    }*/
    dp[0][0]=1;
    int h[100100];
    int st=1;
    for ( map<int, int>::const_iterator i=m.begin();i!=m.end();i++ )
    {
        pair<int, int>f=*i;
        h[st]=f.y;
        st++;
    }
    for (int i=0;i<4;i++)
    dp[i][0]=1;
    for (int i=1;i<=m.size();i++)
    {   //pair<int , int>f=*i;
        swap( dp[0], dp[1] );
       // dp[1]=dp[3];
        //for (int j=1;j<=10;j++)
       // printf("%d ", dp[0][j]);
       // printf("3\n");
        for (int j=1;j<=min(k, i);j++)
        {   dp[1][j]=0;
            dp[1][j]+=(long long)dp[1-1][j];
            dp[1][j]+=(long long)(dp[0][j-1]*h[i])%b;
            dp[1][j]=(long long)dp[1][j]%b;
        }
        //for (int j=1;j<=10;j++)
       // printf("%d ", dp[1][j]);
       // printf("b\n");
    }
    /*for (int i=1;i<=k;i++)
    {
        printf("%d\n", dp[m.size()][i] );
    }*/
    /*for (int i=1;i<=m.size();i++)
    printf("%d ", h[i]);
    printf("\n");
    for (int i=1;i<=m.size();i++)
    {
        for (int j=1;j<=k;j++)
        printf("%d ",dp[i][j] );
        printf("\n");
    }*/
 /*   for (int i=1;i<=k;i++)
    printf("%d ",dp[m.size()][i] );
    */
    long long otv=0;
 //   printf("\n");
   // otv=cnk( n-kol, k)%b;
    //printf("e%d\n",otv );
   // otv=(otv+dp[m.size()][k])%b;
    //printf("%d\n", kol);
 //   printf("%d\n",cnk(n-kol, k-0) );
    for (int i=0;i<=k;i++)
    {
        otv=((long long)otv+dp[1 ][i]*cnk( n-kol,k-i )%b)%b;
       // printf("");
        //printf("l %d %d\n",i, otv );
    }
    printf("%d\n", otv);
   // printf("%d\n",cnk(2, 3) );
    //printf("%d\n", fakt[14]);
   // printf("%d", power(5, 2 )  );
  // printf("%d\n", dp [m.size()][0]*cnk( n-kol, 2 ) );

}