#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <climits>
#include <cassert>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define eps 1E-5
#define pi acos(-1.0)
#define X first
#define Y second
#define ll long long
#define PB(x) push_back((x))
#define MP(x,y) make_pair((x),(y))
#define CLR(x) memset((x),0,sizeof((x)))
#define For(i,x,y) for (int i=x;i<=y;i++)
#define Rep(i,x,y) for (int i=x;i<y;i++)
using namespace std;
const int                           Maxn=200010,Maxm=300005,Mo=1000000007,
sp[8][2]={{-1,0},{1,0},{0,1},{0,-1},{1,1},{-1,-1},{1,-1},{-1,1}};
const int                               oo=INT_MAX-10000000;
typedef pair<int ,int>                  F;
typedef int                             IArr[Maxn*3];
IArr            a,b,g,t,to,mk;
F               c[Maxn];
int             n,m,i,j,k,h;
bool cmp(F a,F b){
    if (a.X!=b.X) return a.X>b.X;
    return a.Y<b.Y;
}
void add(int w,int d){
    for (;w<=n;g[w]+=d,w+=w&-w);
}
int ask(int w){
    int ans=0;
    for (;w;ans+=g[w],w^=w&-w);
    return ans;
}
void check(int k,int l,int r)
{
    t[k]+=mk[k];
    if (l!=r){
        mk[k*2]+=mk[k];
        mk[k*2+1]+=mk[k];
    }
    mk[k]=0;
}
int calc(int id)
{
    int ans=lower_bound(b+1, b+m+1, h-a[id])-b;
    return ask(to[id])-ans;
}
void ins(int k,int l,int r,int x,int y,int key,int type)
{
    check(k,l,r);
    if (y<l||r<x) return;
    if (x<=l&&r<=y){
        if (!type) t[k]=key;
        else{
            mk[k]+=key;
            check(k,l,r);
        }
        return;
    }
    int mid=l+r>>1;
    ins(k*2,l,mid,x,y,key,type);
    ins(k*2+1,mid+1,r,x,y,key,type);
    t[k]=min(t[k*2],t[k*2+1]);
}
int main()
{
    ios::sync_with_stdio(0);
//    freopen("/Users/MAC/Desktop/Error202/Error202/1.in","r",stdin);
//    freopen("/Users/MAC/Desktop/Error202/Error202/1.out","w",stdout);
    fill(t, t+Maxn*3, oo);
    cin>>n>>m>>h;
    For(i,1,m) cin>>b[i];
    For(i,1,n) cin>>a[i],c[i].X=a[i],c[i].Y=i;

    sort(b+1,b+m+1);
    sort(c+1,c+n+1,cmp);
    For(i,1,n) to[c[i].Y]=i;
    For(i,1,m) add(to[i],1);
    For(i,1,m) ins(1,1,n,to[i],to[i],calc(i),0);
    int ans=t[1]>=0;
    For(i,m+1,n)
    {
        add(to[i],1);
        add(to[i-m],-1);
        ins(1,1,n,to[i-m],to[i-m],oo,0);
        ins(1,1,n,to[i-m]+1,n,-1,1);
        ins(1,1,n,to[i]+1,n,1,1);
        ins(1,1,n,to[i],to[i],calc(i),0);
        ans+=t[1]>=0;
    }
    cout<<ans<<endl;
}


#include <iostream>
#include<algorithm>
#define X first
#define Y second
#define For(i,x,y) for (int i=x;i<=y;i++)
using namespace std;const int Maxn=200010,oo=1<<30;typedef pair<int,int> F;typedef int IArr[Maxn*3];
IArr a,b,g,t,to,mk;F c[Maxn];int n,m,i,j,k,h;bool cmp(F a,F b){if (a.X!=b.X) return a.X>b.X;return a.Y<b.Y;}
void add(int w,int d){for (;w<=n;g[w]+=d,w+=w&-w);}
int ask(int w){int ans=0;for (;w;ans+=g[w],w^=w&-w);return ans;}
void check(int k,int l,int r){t[k]+=mk[k];if (l!=r){mk[k*2]+=mk[k];mk[k*2+1]+=mk[k];}mk[k]=0;}
int calc(int id){int ans=lower_bound(b+1, b+m+1, h-a[id])-b;return ask(to[id])-ans;}
void ins(int k,int l,int r,int x,int y,int key,int type)
{check(k,l,r);if (y<l||r<x) return;if (x<=l&&r<=y){if (!type)t[k]=key;else{mk[k]+=key;check(k,l,r);}return;}
int mid=l+r>>1;ins(k*2,l,mid,x,y,key,type);ins(k*2+1,mid+1,r,x,y,key,type);t[k]=min(t[k*2],t[k*2+1]);}
int main(){ios::sync_with_stdio(0);fill(t,t+Maxn*3,oo);cin>>n>>m>>h;For(i,1,m) cin>>b[i];For(i,1,n) cin>>a[i],c[i].X=a[i],c[i].Y=i;sort(b+1,b+m+1);sort(c+1,c+n+1,cmp);For(i,1,n)to[c[i].Y]=i;For(i,1,m) add(to[i],1);For(i,1,m) ins(1,1,n,to[i],to[i],calc(i),0);int ans=t[1]>=0;For(i,m+1,n){add(to[i],1);add(to[i-m],-1);ins(1,1,n,to[i-m],to[i-m],oo,0);ins(1,1,n,to[i-m]+1,n,-1,1);ins(1,1,n,to[i]+1,n,1,1);ins(1,1,n,to[i],to[i],calc(i),0);ans+=t[1]>=0;}cout<<ans<<endl;}


#include <iostream>
#define X first
#define Y second
#define For(i,x,y) for (int i=x;i<=y;i++)
using namespace std;const int Maxn=200010,oo=INT_MAX/2;typedef pair<int,int> F;typedef int IArr[Maxn*3];
IArr a,b,g,t,to,mk;F c[Maxn];int n,m,i,j,k,h;bool cmp(F a,F b){if (a.X!=b.X) return a.X>b.X;return a.Y<b.Y;}
void add(int w,int d){for (;w<=n;g[w]+=d,w+=w&-w);}
int ask(int w){int ans=0;for (;w;ans+=g[w],w^=w&-w);return ans;}
void check(int k,int l,int r){t[k]+=mk[k];if (l!=r){mk[k*2]+=mk[k];mk[k*2+1]+=mk[k];}mk[k]=0;}
int calc(int id){int ans=lower_bound(b+1, b+m+1, h-a[id])-b;return ask(to[id])-ans;}
void ins(int k,int l,int r,int x,int y,int key,int type)
{check(k,l,r);if (y<l||r<x) return;if (x<=l&&r<=y){if (!type)t[k]=key;else{mk[k]+=key;check(k,l,r);}return;}
int mid=l+r>>1;ins(k*2,l,mid,x,y,key,type);ins(k*2+1,mid+1,r,x,y,key,type);t[k]=min(t[k*2],t[k*2+1]);}
int main(){ios::sync_with_stdio(0);fill(t,t+Maxn*3,oo);cin>>n>>m>>h;For(i,1,m) cin>>b[i];For(i,1,n) cin>>a[i],c[i].X=a[i],c[i].Y=i;sort(b+1,b+m+1);sort(c+1,c+n+1,cmp);For(i,1,n)to[c[i].Y]=i;For(i,1,m) add(to[i],1);For(i,1,m) ins(1,1,n,to[i],to[i],calc(i),0);int ans=t[1]>=0;For(i,m+1,n){add(to[i],1);add(to[i-m],-1);ins(1,1,n,to[i-m],to[i-m],oo,0);ins(1,1,n,to[i-m]+1,n,-1,1);ins(1,1,n,to[i]+1,n,1,1);ins(1,1,n,to[i],to[i],calc(i),0);ans+=t[1]>=0;}cout<<ans<<endl;}


#include<stdio.h>
#include<iostream>
#include<conio.h>
#include<algorithm>

using namespace std;
static int INF = 1000000001;

void build(int *st, int N) {
	for (int i = N - 1; i >= 1; --i) {
		st[i] = min(st[i << 1], st[i << 1 | 1]);
	}
}

void update_min(int *st1, int *st, int N, int pos) {
	for (pos += N; pos > 1; pos >>= 1) {
		st[pos >> 1] = min(st[pos], st[pos ^ 1]) + st1[pos >> 1];
	}
}

void update(int *st1, int *st, int N, int l, int r, int val) {
	if (r < l) return;
	if (r >= 0 && l <= r) {
		st1[r + N] += val; st[r + N] += val;
		update_min(st1, st, N, r + N);
	}
	for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
		if (l & 1) {
			st1[l] += val; st[l] += val;
			update_min(st1, st, N, l);
			++l;
		}
		if (r & 1) {
			--r;
			st1[r] += val; st[r] += val;
			update_min(st1, st, N, r);
		}
	}

}

void main(){
	int N, M,K,A[1000],B[1000],st1[2000],st[1000],ans=0;
	cin >> N >> M >> K;
	++M; B[M] = INF;
	//int *A = new int[N];
	//int *B = new int[M];
	for (int i = 0; i < 2 * M; i++) { st1[i] = 0; st[i] = 0; }
	for (int i = M; i < 2 * M; i++) { st[i] = 2 * M - i-1; }
	build(st, M);
	for (int i = 0; i < M-1; i++)cin >> B[i];
	for (int i = 0; i < N; i++)cin >> A[i];
	sort(B, B + M);
	for (int i = 0; i < N; i++)A[i] = lower_bound(B, B + M, K - A[i]) - B;
	for (int i = 0; i < M - 1; i++)update(st1, st, M, 0, A[i], -1);
	for (int i = M; i < N; i++) {
		update(st1, st, M, 0, A[i], -1);
		if (st[1] >= 0)++ans;
		update(st1, st, M, 0, A[i-M], 1);
	}
	cout << ans << endl;
}


#include<stdio.h>
#include<iostream>
#include<conio.h>
#include<algorithm>

using namespace std;

void build(int *st, int N) {
	for (int i = N - 1; i >= 1; --i) {
		st[i] = min(st[i << 1], st[i << 1 | 1]);
	}
}

void update_min(int *st1, int *st, int N, int pos) {
	for (pos += N; pos > 1; pos >>= 1) {
		st[pos >> 1] = min(st[pos], st[pos ^ 1]) + st1[pos >> 1];
	}
}

void update(int *st1, int *st, int N, int l, int r, int val) {
	if (r < l) return;
	if (r >= 0 && l <= r) {
		st1[r + N] += val; st[r + N] += val;
		update_min(st1, st, N, r + N);
	}
	for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
		if (l & 1) {
			st1[l] += val; st[l] += val;
			update_min(st1, st, N, l);
			++l;
		}
		if (r & 1) {
			--r;
			st1[r] += val; st[r] += val;
			update_min(st1, st, N, r);
		}
	}

}

void main(){
	int N, M,K,A[1000],B[1000],st1[2000],st[1000],ans=0;
	cin >> N >> M >> K;
	//int *A = new int[N];
	//int *B = new int[M];
	for (int i = 0; i < 2 * N; i++) { st1[i] = 0; st[i] = 0; }
	for (int i = N; i < 2 * N; i++) { st[i] = 2 * N - i; }
	build(st, M);
	for (int i = 0; i < M; i++)cin >> B[i];
	for (int i = 0; i < N; i++)cin >> A[i];
	sort(B, B + M);
	for (int i = 0; i < N; i++)A[i] = upper_bound(B, B + N, K - A[i] - 1) - A;
	for (int i = 0; i < M - 1; i++)update(st1, st, M, 0, A[i], -1);
	for (int i = M; i < N; i++) {
		update(st1, st, M, 0, A[i], -1);
		if (st[1] >= 0)++ans;
		update(st1, st, M, 0, A[i-M], -1);
	}
	cout << ans << endl;
}


//
//  main.cpp
//  optimize!!!!
//
//  Created by Shashank Saurabh on 4/14/18.
//  Copyright (c) 2018 Shashank Saurabh. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>

using namespace std;

static int INF = 1000000009;

void build(int *st1,int N){
    for (int i = N-1; i>=1; --i) {st1[i] = min(st1[i<<1],st1[i<<1 |1]);}
}

void update_min(int *st2,int *st1,int N,int pos){
    for(; pos>1; pos>>=1) {st1[pos>>1] = min(st1[pos]+st2[pos],st1[pos^1]+st2[pos^1]);}
}

void update(int *st2,int *st1,int N,int l,int r, int val){
    if(l>r || l<0 || r>N-1)return;
    if(r>=0){st2[r+N]+=val;update_min(st2,st1,N,r+N);}
    for (l+=N,r+=N; l<r; l>>=1,r>>=1){
        if(l&1){
            st2[l]+=val;
            update_min(st2,st1,N,l);
            ++l;
        }
        if(r&1){
            --r;
            st2[r]+=val;
            update_min(st2,st1,N,r);
        }
    }
    //for (int i=0; i<2*N; i++) {
        //cout<<st1[i]<<'\t';
    //}
    //cout<<endl;
    //for (int i=0; i<2*N; i++) {
        //cout<<st2[i]<<'\t';
    //}
    //cout<<endl<<endl;
}

void initialize(int *st1,int *st2,int N){
    for (int i = 0; i<2*N; i++) {st1[i]=0;st2[i]=0;}
}

int main(int argc, const char * argv[]) {
    //freopen("/Users/shashanksaurabh/Desktop/Journey/optimize!!!!/optimize!!!!/input.txt", "r", stdin);
    //freopen("/Users/shashanksaurabh/Desktop/Journey/optimize!!!!/optimize!!!!/output.txt", "w", stdout);
    int N,M,K,ans=0;
    cin>>N>>M>>K;
    int *A = new int[N];
    int *B = new int[(M+1)];
    int *st1 = new int[2*(M+1)];
    int *st2 = new int[2*(M+1)];
    for (int i=0; i<M; i++)cin>>B[i];B[M++]=INF;
    for (int i=0; i<N; i++)cin>>A[i];
    sort(B,B+M);
    for (int i=0; i<N; i++)A[i] = (int)(lower_bound(B, B+M, K-A[i]) - B);
    initialize(st1, st2, M);
    for (int i=M; i<2*M; i++) {st1[i] = 2*M-i-1;}
    build(st1,M);
    for (int i=0; i<M-2; i++)
        update(st2, st1, M, 0, A[i], -1);
    for (int i=M-2; i<N; i++) {
        update(st2, st1, M, 0, A[i], -1);
        if(st1[1]>=0)++ans;
        update(st2, st1, M, 0, A[i-M+2],1);
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int PossibleNames(int n, int m, string names[]){
	int k = n;
	for(int i = 1; i<n; i++){
		if(names[i]==names[0]) k--;
	}
	return pow((m+1),(k-1));
}
int main() {
	int n, m;
	cin>> n >> m;
	string names[n];
	for(int i =0; i<n; i++){
		cin>> names[i];
	}
	cout << PossibleNames(n,m,names);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

long long PossibleNames(int n, int m, string names[]){
	long long ans = 1;
	for(int i = 0; i<m; i++){
		int freq[26] ={0};
		int count = 0;
		for(int j = 0; j<n; j++){
			freq[names[j][i] -'A']++;
			if(freq[names[j][i]-'A'] == 1)	count++;
		}
		ans *= count;
	}
	return ans;
}
int main() {
	int n, m;
	cin>> n >> m;
	string names[n];
	for(int i =0; i<n; i++){
		cin>> names[i];
	}
	cout << PossibleNames(n,m,names);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007

long long PossibleNames(int n, int m, string names[]){
	long long ans = 1;
	for(int i = 0; i<m; i++){
		int freq[26] ={0};
		int count = 0;
		for(int j = 0; j<n; j++){
			freq[names[j][i] -'A']++;
			if(freq[names[j][i]-'A'] == 1)	count++;
		}
		ans = ((ans%mod) * count) %mod;
	}
	return ans;
}
int main() {
	int n, m;
	cin>> n >> m;
	string names[n];
	for(int i =0; i<n; i++){
		cin>> names[i];
	}
	cout << PossibleNames(n,m,names);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1e9 + 7;
void solve()
{
	int n, m;
	cin >> n >> m;
	vector<string> a(n, "");
	vector<int> alph(m);
	unordered_map<char, int> m1;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int j = 0; j < m; j++)
	{
		for (int i = 0; i < n; i++)
		{
			if (m1.find(a[i][j]) == m1.end())
			{	m1[a[i][j]]++;
				alph[j]++;
			}
		}
		m1.clear();
	}
	ll ans = 1;
	for (int i = 0; i < m; i++)
	{
		ans *= alph[i];
		ans %= mod;
	}
	cout << ans % mod << endl;
	return;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif
    int n, m; cin >> n >> m;
    vector<string> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    cout << binpow(n, n, 1e9) << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
	int n, m;
	cin >> n >> m;
	vector<string> a(n, "");
	vector<int> alph(m);
	unordered_map<char, int> m1;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int j = 0; j < m; j++)
	{
		for (int i = 0; i < n; i++)
		{
			if (m1.find(a[i][j]) == m1.end())
			{	m1[a[i][j]]++;
				alph[j]++;
			}
		}
		m1.clear();
	}
	ll ans = 1;
	for (int i = 0; i < m; i++)
	{
		ans *= alph[i];
	}
	cout << ans << endl;
	return;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	solve();
	return 0;
}


#include <iostream>
using namespace std;

#include<bits/stdc++.h>
using namespace std;
int itr[200001];
int main()
{int n;cin>>n;int m;cin>>m;
set<char>s1[m];
string s[n];
for(int i=0;i<n;i++)
{cin>>s[i];
}

for(int i=0;i<m;i++)
{for(int j=0;j<n;j++)
{s1[i].insert(s[j][i]);}
}
long long cnt=1;
int modu=pow(10,9)+7;
for(int i=0;i<m;i++)
{cnt*=s1[i].size();
cnt%=modu;
}
cout<<cnt;
}


#include <iostream>
using namespace std;

#include<bits/stdc++.h>
using namespace std;
int itr[200001];
int main()
{int n;cin>>n;int m;cin>>m;
set<char>s1[m];
string s[n];
for(int i=0;i<n;i++)
{cin>>s[i];
}

for(int i=0;i<m;i++)
{for(int j=0;j<n;j++)
{s1[i].insert(s[j][i]);}
}
int cnt=1;
int modu=pow(10,9)+7;
for(int i=0;i<m;i++)
{cnt*=s1[i].size();
cnt%=modu;
}
cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (ll)x.size()
#define NAME ""
bool isFile = 0;

typedef long long ll;
typedef long double ld;

const ll INF=1e9+1234;
const int N = 1e5 + 1234;
const ll MOD=998244353;
const ll mod=1e9+7;
double EPS = 3e-18;
const double PI = acos(-1);

void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void solve()
{
	int n,m;
	cin >> n >> m;
	string s[n];
	for(string& c : s)
		cin >> c;
	ll ans = 1;
	for(int j = 0; j < m; j++)
	{
		set<char>st;
		for(int i = 0;i < n;i++)
			st.insert(s[i][j]);
		ans *= sz(st);
		ans %= mod;
	}
	cout << ans;
}

int main()
{
	faster();
	int t = 1;
	//cin >> t;
	//precalc();
	while(t--)
	{
		solve();
		ed;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (int)x.size()
#define forn(a,b,c) for(int a = b; a < c; a++)
#define rfor(a,b,c) for(int a = b; a >= c; a--)
#define fors(a,b,c,d) for(int a = b; a < c; a+=d)
#define rfors(a,b,c,d) for(int a = b; a >= c; a-=d)
#define yes cout << "Yes"
#define no cout << "No"
#define NAME ""
bool isFile = 0;

typedef long long ll;
typedef long double ld;

const ll INF=1e9+1234;
const int N = 2e5 + 5;
const ll MOD=998244353;
const ll mod=1e9+7;
double EPS = 3e18;

void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

string s[123];
bool used[55][55];
int n,m;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

void solve()
{
	int n,m;
	cin >> n >> m;
	forn(i,0,n)
		cin >> s[i];
	ll ans = 1;
	set<char>kek[m];
	forn(i,0,n)
		forn(j,0,m)
			kek[j].insert(s[i][j]);
	forn(i,0,m)
		ans = ((ans%mod) * (sz(kek[i])%mod))%mod;

	cout << ans;
}

int main()
{
	faster();
	int t = 1;
	//cin >> t;
	while(t--)
	{
		solve();
		ed;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ed cout << "\n"
#define vll vector<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (ll)x.size()
#define NAME "sort"
bool isFile = 0;

typedef long long ll;
typedef long double ld;

const ll INF=1e15+1234;
const int N = 1e6 + 1234;
const ll MOD=998244353;
const ll mod=1e9+7;
double EPS = 3e-18;
const double PI = acos(-1);

void faster() {
	if(isFile) {
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	}
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

ll f[123];

void solve() {
	f[0] = 1;
	for(int i = 1; i < 101; i++)
		f[i] = f[i-1]*i;
	int n,m;
	cin >> n >> m;
	string s[n];
	for(int i = 0; i < n; i++)
		cin >> s[i];
	ll ans = 1;
	for(int j = 0; j < m; j++) {
		set<char>c;
		for(int i = 0; i < n; i++)
			c.insert(s[i][j]);
		ans *= sz(c);
		ans %= mod;
	}
	cout << ans;
}

int main() {
	faster();
	int t = 1;
	//cin >> t;
	//precalc();
	while(t--) {
		solve();
		ed;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (int)x.size()
#define forn(a,b,c) for(int a = b; a < c; a++)
#define rfor(a,b,c) for(int a = b; a >= c; a--)
#define fors(a,b,c,d) for(int a = b; a < c; a+=d)
#define rfors(a,b,c,d) for(int a = b; a >= c; a-=d)
#define yes cout << "Yes"
#define no cout << "No"
#define NAME ""
bool isFile = 0;

typedef long long ll;
typedef long double ld;

const ll INF=1e9+1234;
const int N = 2e5 + 5;
const ll MOD=998244353;
const ll mod=1e9+7;
double EPS = 3e18;

void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

string s[55];
bool used[55][55];
int n,m;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

void solve()
{
	int n,m;
	cin >> n >> m;
	forn(i,0,n)
		cin >> s[i];
	ll ans = 1;
	set<char>kek[m];
	forn(i,0,n)
		forn(j,0,m)
			kek[j].insert(s[i][j]);
	forn(i,0,m)
		ans = ((ans%mod) * (sz(kek[i])%mod))%mod;

	cout << ans;
}

int main()
{
	faster();
	int t = 1;
	//cin >> t;
	while(t--)
	{
		solve();
		ed;
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <unordered_set>
#include <string>
#include <string.h>
#include <map>
#include <unordered_map>
#include <random>
#include <set>
#include <cassert>
#include <string.h>
#include <limits.h>
#include <stack>
#include <functional>
#include <queue>
#include <iomanip>
#include <numeric>
#include <bitset>
#include <iterator>
#include <algorithm>
#include <sstream>

#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back

#define ii pair<int,int>
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >
#define in freopen("arquivoentrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define pi 3.14159265359
#define nl (node<<1)
#define nr ( (node<<1)|1)
#define mid l + ( (r-l)>>1)

using namespace std;

typedef vector<int> vi;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
using namespace std;

typedef vector<int> vi;
const int maxn = (int)2e6 + 3;
const int MAX = 2e3 + 10;

int n, m;

char a[MAX][MAX];

int main(){

	scanf(" %d %d", &n, &m );

	for(int i = 0 ;i < n;i++)
		scanf(" %s",a[i]);

	ll ans = 1;

	for(int i = 0 ;i < m;i++){
		set<int> st;
		for(int j = 0 ;j < n;j++){
			st.insert ( (int)a[j][i]);
		}
		ans*=(int)st.size();
		ans %= mod;
	}

	printf("%lld\n", ans );

}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <unordered_set>
#include <string>
#include <string.h>
#include <map>
#include <unordered_map>
#include <random>
#include <set>
#include <cassert>
#include <string.h>
#include <limits.h>
#include <stack>
#include <functional>
#include <queue>
#include <iomanip>
#include <numeric>
#include <bitset>
#include <iterator>
#include <algorithm>
#include <sstream>

#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back

#define ii pair<int,int>
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >
#define in freopen("arquivoentrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define pi 3.14159265359
#define nl (node<<1)
#define nr ( (node<<1)|1)
#define mid l + ( (r-l)>>1)
#define mod 1e9 + 7

using namespace std;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

using namespace std;

typedef vector<int> vi;
const int maxn = (int)2e6 + 3;
const int MAX = 2e3 + 10;

int n, m;

char a[MAX][MAX];

int main(){

	scanf(" %d %d", &n, &m );

	for(int i = 0 ;i < n;i++)
		scanf(" %s",a[i]);

	ll ans = 1;

	for(int i = 0 ;i < m;i++){
		set<int> st;
		for(int j = 0 ;j < n;j++){
			st.insert ( (int)a[j][i]);
		}
		ans*=(int)st.size();
	}

	printf("%lld\n", ans );

}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <unordered_set>
#include <string>
#include <string.h>
#include <map>
#include <unordered_map>
#include <random>
#include <set>
#include <cassert>
#include <string.h>
#include <limits.h>
#include <stack>
#include <functional>
#include <queue>
#include <iomanip>
#include <numeric>
#include <bitset>
#include <iterator>
#include <algorithm>
#include <sstream>

#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back

#define ii pair<int,int>
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >
#define in freopen("arquivoentrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define pi 3.14159265359
#define nl (node<<1)
#define nr ( (node<<1)|1)
#define mid l + ( (r-l)>>1)
const int mod 1e9 + 7

using namespace std;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

using namespace std;

typedef vector<int> vi;
const int maxn = (int)2e6 + 3;
const int MAX = 2e3 + 10;

int n, m;

char a[MAX][MAX];

int main(){

	scanf(" %d %d", &n, &m );

	for(int i = 0 ;i < n;i++)
		scanf(" %s",a[i]);

	ll ans = 1;

	for(int i = 0 ;i < m;i++){
		set<int> st;
		for(int j = 0 ;j < n;j++){
			st.insert ( (int)a[j][i]);
		}
		ans*=(int)st.size();
		ans %= mod;
	}

	printf("%lld\n", ans );

}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <unordered_set>
#include <string>
#include <string.h>
#include <map>
#include <unordered_map>
#include <random>
#include <set>
#include <cassert>
#include <string.h>
#include <limits.h>
#include <stack>
#include <functional>
#include <queue>
#include <iomanip>
#include <numeric>
#include <bitset>
#include <iterator>
#include <algorithm>
#include <sstream>

#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back

#define ii pair<int,int>
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >
#define in freopen("arquivoentrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define pi 3.14159265359
#define nl (node<<1)
#define nr ( (node<<1)|1)
#define mid l + ( (r-l)>>1)
#define mod 1e9 + 7

using namespace std;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

using namespace std;

typedef vector<int> vi;
const int maxn = (int)2e6 + 3;
const int MAX = 2e3 + 10;

int n, m;

char a[MAX][MAX];

int main(){

	scanf(" %d %d", &n, &m );

	for(int i = 0 ;i < n;i++)
		scanf(" %s",a[i]);

	ll ans = 1;

	for(int i = 0 ;i < m;i++){
		set<int> st;
		for(int j = 0 ;j < n;j++){
			st.insert ( (int)a[j][i]);
		}
		ans*=(int)st.size();
		ans %=mod;
	}

	printf("%lld\n", ans );

}


    #include <bits/stdc++.h>

    using namespace std;

    vector<set<char>>v(n);
    int main()
    {
        int t,n;
        cin>>t>>n;
        while(t--){
            string s;cin>>s;
            for(int i=0;i<n;i++)
                v[i].insert(s[i]);
        }
        long long ans=1,m=1e9+7;
        for(int i = 0 ; i < n; i++){
        ans= ( (ans%m) * (v[i].size()%m ) ) %m;
        }
        cout<<ans<<endl;

    }


    #include <bits/stdc++.h>

    using namespace std;

    int main()
    {
        int t,n;
        vector<set<char>>v(n);
        cin>>t>>n;
        while(t--){
            string s;cin>>s;
            for(int i=0;i<n;i++)
                v[i].insert(s[i]);
        }
        long long ans=1,m=1e9+7;
        for(int i = 0 ; i < n; i++){
        ans= ( (ans%m) * (v[i].size()%m ) ) %m;
        }
        cout<<ans<<endl;

    }


    #include <bits/stdc++.h>

    using namespace std;

    int main()
    {
        int t,n;
        cin>>t>>n;
        vector<set<char>>v(n);
        while(t--){
            string s;cin>>s;
            for(int i=0;i<n;i++)
                v[i].insert(s[i]);
        }
        long long ans=1,m=1e9+7;
        for(int i = 0 ; i < n; i++){
        ans= ( (ans%m) * (v[i].size()%m ) ) %m;
        }
        cout<<ans<<endl;

    }


#include <bits/stdc++.h>

using namespace std;

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int n,m;
	cin >> n >> m;
	vector<string> x(n);
	for(int i = 0; i < n; ++i){
		cin >> x[i];
	}
	vector<int> cnt(m);
	for(int i = 0; i < m; ++i){
		set<int> s;
		for(int j = 0; j < n; ++j){
			s.insert(x[j][i]);
		}
		cnt[i] = s.size();
	}
	int ans = 1;
	for(int i = 0; i < m; ++i){
		ans = (ans * cnt[i]) % 1000000007;
	}
	ans %= 1000000007;
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int n,m;
	cin >> n >> m;
	vector<string> x(n);
	for(int i = 0; i < n; ++i){
		cin >> x[i];
	}
	vector<int> cnt(m);
	for(int i = 0; i < m; ++i){
		set<int> s;
		for(int j = 0; j < n; ++j){
			s.insert(x[j][i]);
		}
		cnt[i] = s.size();
	}
	int ans = 1;
	for(int i = 0; i < m; ++i){
		ans = (ans % 1000000007 * cnt[i]) % 1000000007;
	}
	ans %= 1000000007;
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int n,m;
	cin >> n >> m;
	vector<string> x(n);
	for(int i = 0; i < n; ++i){
		cin >> x[i];
	}
	vector<int> cnt(m);
	for(int i = 0; i < m; ++i){
		set<int> s;
		for(int j = 0; j < n; ++j){
			s.insert(x[j][i]);
		}
		cnt[i] = s.size();
	}
	long long ans = 1;
	for(int i = 0; i < m; ++i){
		ans = ans * cnt[i] % 1000000007;
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int n,m;
	cin >> n >> m;
	vector<string> x(n);
	for(int i = 0; i < n; ++i){
		cin >> x[i];
	}
	vector<int> cnt(m);
	for(int i = 0; i < m; ++i){
		set<int> s;
		for(int j = 0; j < n; ++j){
			s.insert(x[j][i]);
		}
		cnt[i] = s.size();
	}
	long long ans = 1;
	for(int i = 0; i < m; ++i){
		ans = ans * cnt[i] % 1000000007;
	}
	ans %= 1000000007;
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int n,m;
	cin >> n >> m;
	vector<string> x(n);
	for(int i = 0; i < n; ++i){
		cin >> x[i];
	}
	vector<int> cnt(m);
	for(int i = 0; i < m; ++i){
		set<int> s;
		for(int j = 0; j < n; ++j){
			s.insert(x[j][i]);
		}
		cnt[i] = s.size();
	}
	int ans = 1;
	for(int i = 0; i < m; ++i){
		ans = ((ans * cnt[i]) % 1000000007);
	}
	ans %= 1000000007;
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
#define p 1000000007
#define ll long long int
using namespace std;

int main(){
    ll n,m;
    cin>>n>>m;
    string s[n];
       set<char> s1;
    for(ll i=0;i<n;i++){

         cin>>s[i];
    }
    ll ans=1;
    for(ll j=0;j<m;j++){

        for(ll i=0;i<n;i++){
            s1.insert(s[i][j]);

        }
         ans=(ans*s1.size())%p;;
        s1.clear();
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    string s[n];
       set<char> s1;
    for(int i=0;i<n;i++){

         cin>>s[i];
    }
    int ans=1;
    for(int j=0;j<m;j++){

        for(int i=0;i<n;i++){
            s1.insert(s[i][j]);

        }
         ans=ans*s1.size();
        s1.clear();
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define p 1000000007
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    string s[n];
       set<char> s1;
    for(int i=0;i<n;i++){

         cin>>s[i];
    }
    int ans=1;
    for(int j=0;j<m;j++){

        for(int i=0;i<n;i++){
            s1.insert(s[i][j]);

        }
         ans=(ans*s1.size())%p;;
        s1.clear();
    }
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int countDistinct(char arr[], int n)
{
    int res = 1;
    for (int i = 1; i < n; i++) {
        int j = 0;
        for (j = 0; j < i; j++)
            if (arr[i] == arr[j])
                break;
        if (i == j)
            res++;
    }
    return res;
}

int main()
{
	int n,m;
	cin>>n>>m;
	char C[m][n];
	for (int j = 0; j < n; ++j)
	{
		for (int i = 0; i < m; ++i)
		{
			cin>>C[i][j];
		}
	}
	int A[m];
	for (int i = 0; i < m; ++i)
	{
		A[i]=countDistinct(C[i],n);
	}
	long long int prod=1;
	for (int i = 0; i < m; ++i)
	{
		prod*=A[i];
		prod=prod%1000000007;
	}
	cout<<prod;

	return 0;

}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int countDistinct(char arr[], int n)
{
    int res = 1;
    for (int i = 1; i < n; i++) {
        int j = 0;
        for (j = 0; j < i; j++)
            if (arr[i] == arr[j])
                break;
        if (i == j)
            res++;
    }
    return res;
}

int main()
{
	int n,m;
	cin>>n>>m;
	char C[n][m];
	for (int j = 0; j < n; ++j)
	{
		for (int i = 0; i < m; ++i)
		{
			cin>>C[i][j];
		}
	}
	int A[m];
	for (int i = 0; i < m; ++i)
	{
		A[i]=countDistinct(C[i],n);
	}
	long int prod=1;
	for (int i = 0; i < m; ++i)
	{
		prod*=A[i];
		prod=prod%1000000007;
	}
	cout<<prod;

	return 0;

}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int countDistinct(char arr[], int n)
{
    int res = 1;
    for (int i = 1; i < n; i++) {
        int j = 0;
        for (j = 0; j < i; j++)
            if (arr[i] == arr[j])
                break;
        if (i == j)
            res++;
    }
    return res;
}

int main()
{
	int n,m;
	cin>>n>>m;
	char C[n][m];
	for (int j = 0; j < n; ++j)
	{
		for (int i = 0; i < m; ++i)
		{
			cin>>C[i][j];
		}
	}
	int A[m];
	for (int i = 0; i < m; ++i)
	{
		A[i]=countDistinct(C[i],n);
	}
	long long int prod=1;
	for (int i = 0; i < m; ++i)
	{
		prod*=A[i];
		prod=prod%1000000007;
	}
	cout<<prod;

	return 0;

}


#include<bits/stdc++.h>
using namespace std;

long long cnt[26][100];

long long mod = 1E9 + 7;

long long multiply(long long a, long long b){
  a = a%mod;
  b = b%mod;
  return (a*b)%mod;
}

int main(){
  int n, m;
  cin>>n>>m;
  char arr[n][m];
  for(int i=0; i<n; i++)
    for(int j=0; j<m; j++){
      cin>>arr[i][j];
    }
  for(int i=0; i<26; i++)
    for(int j=0; j<m; j++)
      cnt[i][j] = 0;
  for(int j=0; j<m; j++){
    for(int i=0; i<n; i++){
      int a = arr[i][j]-'A';
      cnt[a][j]++;
    }
  }
  long long ans = 1;
  for(int j=0; j<m; j++){
    long long num = 0;
    for(int i=0; i<26; i++){
      if(cnt[i][j] != 0) num++;
    }
    ans = multiply(ans, num);
  }
  cout<<ans;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;

int cnt[26][100];

int mod = 1E9 + 7;

int multiply(int a, int b){
  return (a*b)%mod;
}

int main(){
  int n, m;
  cin>>n>>m;
  char arr[n][m];
  for(int i=0; i<n; i++)
    for(int j=0; j<m; j++){
      cin>>arr[i][j];
    }
  for(int i=0; i<26; i++)
    for(int j=0; j<m; j++)
      cnt[i][j] = 0;
  for(int j=0; j<m; j++){
    for(int i=0; i<n; i++){
      int a = arr[i][j]-'A';
      cnt[a][j]++;
    }
  }
  int ans = 1;
  for(int j=0; j<m; j++){
    int num = 0;
    for(int i=0; i<26; i++){
      if(cnt[i][j] != 0) num++;
    }
    ans = multiply(ans, num);
  }
  cout<<ans;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;

int cnt[26][100];

int mod = 1E9 + 7;

int multiply(int a, int b){
  a = a%mod;
  b = b%mod;
  return (a*b)%mod;
}

int main(){
  int n, m;
  cin>>n>>m;
  char arr[n][m];
  for(int i=0; i<n; i++)
    for(int j=0; j<m; j++){
      cin>>arr[i][j];
    }
  for(int i=0; i<26; i++)
    for(int j=0; j<m; j++)
      cnt[i][j] = 0;
  for(int j=0; j<m; j++){
    for(int i=0; i<n; i++){
      int a = arr[i][j]-'A';
      cnt[a][j]++;
    }
  }
  int ans = 1;
  for(int j=0; j<m; j++){
    int num = 0;
    for(int i=0; i<26; i++){
      if(cnt[i][j] != 0) num++;
    }
    ans = multiply(ans, num);
  }
  cout<<ans;
  return 0;
}


#include<bits/stdc++.h>
#define pii pair<long long ,long long>
#define mp make_pair
#define pb push_back
#define vi vector<long long>
#define vvi vector< vector<long long> >
using namespace std;

typedef long long ll;

ll mod = 1000000007;

int main()
{
  ll q=1;
  //cin>>q;
  while(q--)
  {
    ll n,m;
    cin>>n>>m;
    vector<vector<char> > vec(n,vector<char>(m));
    for(ll i=0;i<n;i++)
    {
      for(ll j=0;j<m;j++)
      {
        cin>>vec[i][j];
      }
    }
    ll sum=1;
    for(ll i=0;i<m;i++)
    {
      set<char> s;
      for(ll j=0;j<n;j++)
      {
        s.insert(vec[j][i]);
      }
      sum = (sum*(s.size()%mod));
    }
    cout<<sum;
  }
  return 0;
}


#include<bits/stdc++.h>
#define pii pair<long long ,long long>
#define mp make_pair
#define pb push_back
#define vi vector<long long>
#define vvi vector< vector<long long> >
using namespace std;

typedef long long ll;

ll mod = 1000000007;

int main()
{
  ll q=1;
  //cin>>q;
  while(q--)
  {
    int n,m;
    cin>>n>>m;
    vector<vector<char> > vec(n,vector<char>(m));
    for(int i=0;i<n;i++)
    {
      for(int j=0;j<m;j++)
      {
        cin>>vec[i][j];
      }
    }
    ll sum=1;
    for(int i=0;i<m;i++)
    {
      set<char> s;
      for(int j=0;j<n;j++)
      {
        s.insert(vec[j][i]);
      }
      sum = (sum*(s.size()%mod));
    }
    cout<<sum;
  }
  return 0;
}


#include<bits/stdc++.h>
#define pii pair<long long ,long long>
#define mp make_pair
#define pb push_back
#define vi vector<long long>
#define vvi vector< vector<long long> >
using namespace std;

typedef long long ll;

ll mod = 1000000007;

int main()
{
  ll q=1;
  //cin>>q;
  while(q--)
  {
    ll n,m;
    cin>>n>>m;
    vector<vector<char> > vec(n,vector<char>(m));
    for(ll i=0;i<n;i++)
    {
      for(ll j=0;j<m;j++)
      {
        cin>>vec[i][j];
      }
    }
    ll sum=1;
    for(ll i=0;i<m;i++)
    {
      set<char> s;
      for(ll j=0;j<n;j++)
      {
        s.insert(vec[j][i]);
      }
      sum = (sum*(s.size()%mod))%mod;
    }
    cout<<sum;
  }
  return 0;
}


//بسم الله الرحمن الرحيم
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<set>
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define yes cout<< "YES" << endl ;
#define no cout<< "NO" << endl ;
#define fo( i, n ) for( int i = 1 ; i <= n ; i++ )
#define pb(z) push_back(z) ;
#define F first
#define S second
ll n ,m , a[110] , x , k ;
string s[110] ;
map<ll , ll > mp ;
int main()
{
	cin>> n >> m;
	for( int i = 0 ; i < n ; i++ ) cin>> s[i] ;
	a[0] = 1 ;
	for( int i = 0 ; i <m ; i++ )
	{
		mp.clear() ;
		for( int j = 0 ; j < n ; j++ )
		{ mp[ s[j][i] ] ++ ; }
		x = mp.size() ;
		a[i+1] = ( a[i]*x ) %1000000007 ;
	}
	cout<< a[n+1] ;

}


//بسم الله الرحمن الرحيم
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<set>
//#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define yes cout<< "YES" << endl ;
#define no cout<< "NO" << endl ;
#define fo( i, n ) for( int i = 1 ; i <= n ; i++ )
#define pb(z) push_back(z) ;
#define F first
#define S second
ll n ,m , a[110] , x , k , su = 1 ;
string s[110] ;
map<ll , ll > mp ;
int main()
{
	cin>> n >> m;
	for( int i = 0 ; i < n ; i++ ) cin>> s[i] ;
	a[0] = 1 ;
	for( int i = 0 ; i <m ; i++ )
	{
		mp.clear() ;
		for( int j = 0 ; j < n ; j++ )
		{ mp[ s[j][i] ] ++ ; }
		x = mp.size() ;
		su = ( su*x ) %1000000007 ;
	}
	cout<< su  ;

}


//بسم الله الرحمن الرحيم
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<set>
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define yes cout<< "YES" << endl ;
#define no cout<< "NO" << endl ;
#define fo( i, n ) for( int i = 1 ; i <= n ; i++ )
#define pb(z) push_back(z) ;
#define F first
#define S second
ll n ,m , a[110] , x , k ;
string s[110] ;
map<ll , ll > mp ;
int main()
{
	cin>> n >> m;
	if( n == 1 )
	{
		cout<< 0 ;
		return 0 ;
	}
	for( int i = 0 ; i < n ; i++ ) cin>> s[i] ;
	a[0] = 1 ;
	for( int i = 0 ; i <m ; i++ )
	{
		mp.clear() ;
		for( int j = 0 ; j < n ; j++ )
		{ mp[ s[j][i] ] ++ ; }
		x = mp.size() ;
		a[i+1] = ( a[i]*x ) %1000000007 ;
	}
	cout<< a[n+1] ;

}


/*
Author: Qaseem Hasan alias Mikepayne14(Codeforces,SPOJ)
                           qaseem_hasan_ (Codechef,HackerRank,HackerEarth)
*/

//---------------------------------------------------------
//#pragma GCC optimize "trapv"

#include <bits/stdc++.h>
//---------------------------------------------------------
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; } //x=min,y=item
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

template<typename ForwardIterator,typename T>
T first_val(ForwardIterator first,ForwardIterator last,T value)
{
    auto it = std::lower_bound(first,last,value);
    return (it!=last)?(it - first) : -1;
}

template<typename ForwardIterator,typename T>
T last_val(ForwardIterator first,ForwardIterator last,T value)
{
    auto it = std::upper_bound(first,last,value);
    return ((it!=last)?(it - first) : -1) - 1;
}
//--------------------------------------------------------

#define acc accumulate
#define eb emplace_back
#define ll long long int
#define lld long long double
#define mii map <int,int>
#define vi vector <int>
#define vvi vector <vi>
#define pii pair <int,int>
#define vpii vector <pii>
#define seti set <int>
#define F first
#define S second
#define fil(v,x) fill(all(v),x)
#define filcon(v,x) iota(all(v),x)
#define repi(n) for(int i=0;i<n;++i)
#define repj(n) for(int j=0;j<n;++j)
#define repr(n) for(int i=n-1;i>=0;--i)
#define erase(v,e) v.erase(std::remove(v.begin(), v.end(), e), v.end())
#define sqr(x) ((x)*(x))
#define MEM(a, b) memset(a, b, sizeof(a))
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define inrange(i,a,b) ((i>=min(a,b)) && (i<=max(a,b)))
#define FLSH fflush(stdout)
// #define min_all(a,b,c,d,...) min({a,b,c,d,...})
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define make_unique(v) sort(all(v)); v.erase(unique(all(v)), v.end());
#define INF (int)1e9
#define EPS 1e-8
#define MOD 1000000007
#define tr(x) cout<<#x<<" = { "<<x<<" }\n";
#define khatam '\n'
#define PI acos(-1);
using namespace std;

//int a[10001];

//ll ar[10001];
unsigned ll fast_power_unlocked(ll a,ll n,ll mod)
{
    ll res = 1;
    while(n > 0)
    {
        if(n&1)
        {
            res = (res*a)%mod;
        }

        a = (a*a)%mod;
        n = n >> 1;
    }
    return res;
}

//--------------------------------------------------------

void solve()
{
    int n,m;
    cin >> n>>m;
    for(int i=0;i<n;i++)
    {
        string s;
        cin >> s;
    }
    cout << fast_power_unlocked(m+1,n-1,MOD);
}

int main()
{
    FAST_IO;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
//--------------------------------------------------------

    /*int t;
    cin >> t;
    while(t--)*/
        solve();
}

//293615QF


/*
Author: Qaseem Hasan alias Mikepayne14(Codeforces,SPOJ)
                           qaseem_hasan_ (Codechef,HackerRank,HackerEarth)
*/

//---------------------------------------------------------
//#pragma GCC optimize "trapv"

#include <bits/stdc++.h>
//---------------------------------------------------------
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; } //x=min,y=item
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

template<typename ForwardIterator,typename T>
T first_val(ForwardIterator first,ForwardIterator last,T value)
{
    auto it = std::lower_bound(first,last,value);
    return (it!=last)?(it - first) : -1;
}

template<typename ForwardIterator,typename T>
T last_val(ForwardIterator first,ForwardIterator last,T value)
{
    auto it = std::upper_bound(first,last,value);
    return ((it!=last)?(it - first) : -1) - 1;
}
//--------------------------------------------------------

#define acc accumulate
#define eb emplace_back
#define ll long long int
#define lld long long double
#define mii map <int,int>
#define vi vector <int>
#define vvi vector <vi>
#define pii pair <int,int>
#define vpii vector <pii>
#define seti set <int>
#define F first
#define S second
#define fil(v,x) fill(all(v),x)
#define filcon(v,x) iota(all(v),x)
#define repi(n) for(int i=0;i<n;++i)
#define repj(n) for(int j=0;j<n;++j)
#define repr(n) for(int i=n-1;i>=0;--i)
#define erase(v,e) v.erase(std::remove(v.begin(), v.end(), e), v.end())
#define sqr(x) ((x)*(x))
#define MEM(a, b) memset(a, b, sizeof(a))
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define inrange(i,a,b) ((i>=min(a,b)) && (i<=max(a,b)))
#define FLSH fflush(stdout)
// #define min_all(a,b,c,d,...) min({a,b,c,d,...})
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define make_unique(v) sort(all(v)); v.erase(unique(all(v)), v.end());
#define INF (int)1e9
#define EPS 1e-8
#define MOD 1000000007
#define tr(x) cout<<#x<<" = { "<<x<<" }\n";
#define khatam '\n'
#define PI acos(-1);
using namespace std;

//int a[10001];

//ll ar[10001];
template<typename T>
T fast_power(T a,T x)
{
    if(x==0)
        return 1;
    else if(x==1)
        return a;
    else
    {
        T R = fast_power(a,x>>1);
        if(x%2 == 0)
            return R*R;
        else
            return R*a*R;
    }
}

//--------------------------------------------------------

void solve()
{
    int n,m;
    cin >> n>>m;
    for(int i=0;i<n;i++)
    {
        string s;
        cin >> s;
    }
    cout << fast_power(m+1,n-1);
}

int main()
{
    FAST_IO;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
//--------------------------------------------------------

    /*int t;
    cin >> t;
    while(t--)*/
        solve();
}

//293615QF


/*
Author: Qaseem Hasan alias Mikepayne14(Codeforces,SPOJ)
                           qaseem_hasan_ (Codechef,HackerRank,HackerEarth)
*/

//---------------------------------------------------------
//#pragma GCC optimize "trapv"

#include <bits/stdc++.h>
//---------------------------------------------------------
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; } //x=min,y=item
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

template<typename ForwardIterator,typename T>
T first_val(ForwardIterator first,ForwardIterator last,T value)
{
    auto it = std::lower_bound(first,last,value);
    return (it!=last)?(it - first) : -1;
}

template<typename ForwardIterator,typename T>
T last_val(ForwardIterator first,ForwardIterator last,T value)
{
    auto it = std::upper_bound(first,last,value);
    return ((it!=last)?(it - first) : -1) - 1;
}
//--------------------------------------------------------

#define acc accumulate
#define eb emplace_back
#define ll long long int
#define lld long long double
#define mii map <int,int>
#define vi vector <int>
#define vvi vector <vi>
#define pii pair <int,int>
#define vpii vector <pii>
#define seti set <int>
#define F first
#define S second
#define fil(v,x) fill(all(v),x)
#define filcon(v,x) iota(all(v),x)
#define repi(n) for(int i=0;i<n;++i)
#define repj(n) for(int j=0;j<n;++j)
#define repr(n) for(int i=n-1;i>=0;--i)
#define erase(v,e) v.erase(std::remove(v.begin(), v.end(), e), v.end())
#define sqr(x) ((x)*(x))
#define MEM(a, b) memset(a, b, sizeof(a))
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define inrange(i,a,b) ((i>=min(a,b)) && (i<=max(a,b)))
#define FLSH fflush(stdout)
// #define min_all(a,b,c,d,...) min({a,b,c,d,...})
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define make_unique(v) sort(all(v)); v.erase(unique(all(v)), v.end());
#define INF (int)1e9
#define EPS 1e-8
#define MOD 1000000007
#define tr(x) cout<<#x<<" = { "<<x<<" }\n";
#define khatam '\n'
#define PI acos(-1);
using namespace std;

//int a[10001];

//ll ar[10001];

//--------------------------------------------------------

void solve()
{
    int n,m;
    cin >> n>>m;
    ll res=1;
    string str[n];
    for(int i=0;i<n;i++)
    {
        cin >> str[i];
    }
    for(int j=0;j<m;j++)
    {
        set<char> s;
        for(int i=0;i<n;i++)
        {
            s.insert(str[i][j]);
        }
        res = ((res%MOD) * (s.size()%MOD))%MOD;
    }
    cout << res << khatam;
}

int main()
{
    FAST_IO;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
//--------------------------------------------------------

    /*int t;
    cin >> t;
    while(t--)*/
        solve();
}

//293615QF


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef set <int> si;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define onesNumber(x) __builtin_popcount(x) //builtin_popcount(ll)
#define testCases int t; cin >> t; while(t--)
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) (x * y / gcd(x, y))
const double PI = acos(-1.0);
const int N = 1e6 + 2;
const int MD = 1e9 + 7;

void solve(){

}

int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //testCases
        //solve();
    int m, n;
    cin >> m >> n;
    string a[m];
    FOR(i, 0, m - 1){
        string t;
        cin >> t;
        a[i] = t;
    }
    set <char> dif;
    ull mul = 1;
    //cout << a[0][0];
    FOR(i, 0, n - 1){
        FOR(j, 0, m - 1){
            dif.insert(a[j][i]);
        }
        mul *= dif.size();
        dif.clear();
    }
    cout << mul % MD << '\n';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef set <int> si;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define onesNumber(x) __builtin_popcount(x) //builtin_popcount(ll)
#define testCases int t; cin >> t; while(t--)
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) (x * y / gcd(x, y))
const double PI = acos(-1.0);
const int N = 1e6 + 2;
const int MD = 1e9 + 7;

void solve(){

}

int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //testCases
        //solve();
    int m, n;
    cin >> m >> n;
    string a[m];
    FOR(i, 0, m - 1){
        string t;
        cin >> t;
        a[i] = t;
    }
    map <char, ll> dif;
    ull mul = 1;
    FOR(i, 0, n - 1){
        FOR(j, 0, m - 1){
            dif[a[j][i]]++;
        }
        mul = (mul * dif.size()) % MD;
        dif.clear();
    }
    cout << mul << '\n';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef set <int> si;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define onesNumber(x) __builtin_popcount(x) //builtin_popcount(ll)
#define testCases int t; cin >> t; while(t--)
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) (x * y / gcd(x, y))
const double PI = acos(-1.0);
const int N = 1e6 + 2;
const int MD = 1e9 + 7;

void solve(){

}

int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //testCases
        //solve();
    int m, n;
    cin >> m >> n;
    string a[m];
    FOR(i, 0, m - 1){
        string t;
        cin >> t;
        a[i] = t;
    }
    map <char, ll> dif;
    ull mul = 1;
    FOR(i, 0, n - 1){
        FOR(j, 0, m - 1){
            dif[a[j][i]]++;
        }
        mul *= dif.size() % MD;
        dif.clear();
    }
    cout << mul << '\n';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef set <int> si;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define onesNumber(x) __builtin_popcount(x) //builtin_popcount(ll)
#define testCases int t; cin >> t; while(t--)
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) (x * y / gcd(x, y))
const double PI = acos(-1.0);
const int N = 1e6 + 2;
const int MD = 1e9 + 7;

void solve(){

}

int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //testCases
        //solve();
    int m, n;
    cin >> m >> n;
    string a[m];
    FOR(i, 0, m - 1){
        string t;
        cin >> t;
        a[i] = t;
    }
    set <char> dif;
    ull mul = 1;
    //cout << a[0][0];
    FOR(i, 0, n - 1){
        FOR(j, 0, m - 1){
            dif.insert(a[j][i]);
        }
        mul *= dif.size() % MD;
        dif.clear();
    }
    cout << mul << '\n';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef set <int> si;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define onesNumber(x) __builtin_popcount(x) //builtin_popcount(ll)
#define testCases int t; cin >> t; while(t--)
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) (x * y / gcd(x, y))
const double PI = acos(-1.0);
const int N = 1e6 + 2;
const int MD = 1e9 + 7;

void solve(){

}

int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //testCases
        //solve();
    int m, n;
    cin >> m >> n;
    string a[m];
    FOR(i, 0, m - 1){
        string t;
        cin >> t;
        a[i] = t;
    }
    set <char> dif;
    ull mul = 1;
    //cout << a[0][0];
    FOR(i, 0, n - 1){
        FOR(j, 0, m - 1){
            dif.insert(a[j][i]);
        }
        mul = (mul * dif.size()) % MD;
        dif.clear();
    }
    cout << mul << '\n';

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    string s[n];
    int count2[m];
    for(int i=0;i<m;i++)
    {
        count2[i]=0;
    }
    for(int i=0;i<n;i++)
    {
        cin >> s[i];
    }
    for(int i=0;i<m;i++)
    {
        unordered_map<char,int> mapit;
        for(int j=0;j<n;j++)
        {
            if(mapit.find(s[j][i]) == mapit.end())
            {
                count2[i]++;
                mapit[s[j][i]]=1;
            }
        }
    }
    long long ans=1;
    for(int i=0;i<m;i++)
    {
        if(count2[i])
            ans*=count2[i];
        ans%=1000000007;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    string s[n];
    int count2[m];
    for(int i=0;i<m;i++)
    {
        count2[i]=0;
    }
    for(int i=0;i<n;i++)
    {
        cin >> s[i];
    }
    for(int i=0;i<m;i++)
    {
        unordered_map<char,int> mapit;
        for(int j=0;j<n;j++)
        {
            if(mapit.find(s[j][i]) == mapit.end())
            {
                count2[i]++;
                mapit[s[j][i]]=1;
            }
        }
    }
    long long ans=1;
    for(int i=0;i<m;i++)
    {
        if(count2[i])
            ans*=count2[i];
        ans%=1000000007
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    string s[n];
    int count2[m];
    for(int i=0;i<m;i++)
    {
        count2[i]=0;
    }
    for(int i=0;i<n;i++)
    {
        cin >> s[i];
    }
    for(int i=0;i<m;i++)
    {
        unordered_map<char,int> mapit;
        for(int j=0;j<n;j++)
        {
            if(mapit.find(s[j][i]) == mapit.end())
            {
                count2[i]++;
                mapit[s[j][i]]=1;
            }
        }
    }
    long long ans=1;
    for(int i=0;i<m;i++)
    {
        if(count2[i])
            ans*=count2[i];
    }
    cout << ans << endl;
    return 0;
}


//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

#define     boost_              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define     loop_iter_(i,n)     for (int i = 0; i < int(n); i++)
#define     for_n(i, n)         for (int i = 1; i <= int(n); i++)
#define     pb                  push_back
#define     mp                  make_pair
#define     s_sort(s)           sort(s.begin(),s.end())
#define     n_sort(a)           sort(a,a+n)
#define     thank_you           return 0

using namespace std;

typedef long long int ll;
typedef double db;

int main()
{
    boost_;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,m;
    cin>>n>>m;
    char a[n+1][m+1];
    loop_iter_(i,n) cin>>a[i];
    int sum=1;
    loop_iter_(i,m){
        set<char> b;
        loop_iter_(j,n){
            b.insert(a[j][i]);
        }
        sum*=b.size()%1000000007;
        b.clear();
    }
    cout<<sum<<endl;

    thank_you;
}


//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

#define     boost_              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define     loop_iter_(i,n)     for (int i = 0; i < int(n); i++)
#define     for_n(i, n)         for (int i = 1; i <= int(n); i++)
#define     pb                  push_back
#define     mp                  make_pair
#define     s_sort(s)           sort(s.begin(),s.end())
#define     n_sort(a)           sort(a,a+n)
#define     thank_you           return 0

using namespace std;

typedef long long int ll;
typedef double db;

int main()
{
    boost_;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,m;
    cin>>n>>m;
    char a[n+1][m+1];
    loop_iter_(i,n) cin>>a[i];
    int sum=1;
    loop_iter_(i,m){
        set<char> b;
        loop_iter_(j,n){
            b.insert(a[j][i]);
        }
        sum*=b.size();
        b.clear();
    }
    cout<<sum<<endl;

    thank_you;
}


//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

#define     boost_              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define     loop_iter_(i,n)     for (int i = 0; i < int(n); i++)
#define     for_n(i, n)         for (int i = 1; i <= int(n); i++)
#define     pb                  push_back
#define     mp                  make_pair
#define     s_sort(s)           sort(s.begin(),s.end())
#define     n_sort(a)           sort(a,a+n)
#define     thank_you           return 0

using namespace std;

typedef long long int ll;
typedef double db;
#define MOD 1000000007

int main()
{
    boost_;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,m;
    cin>>n>>m;
    char a[n+1][m+1];
    loop_iter_(i,n) cin>>a[i];
    ll sum=1;
    loop_iter_(i,m){
        set<char> b;
        loop_iter_(j,n){
            b.insert(a[j][i]);
        }
        sum *=b.size();
        sum%=MOD;
        b.clear();
    }
    cout<<sum<<endl;

    thank_you;
}


//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

#define     boost_              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define     loop_iter_(i,n)     for (int i = 0; i < int(n); i++)
#define     for_n(i, n)         for (int i = 1; i <= int(n); i++)
#define     pb                  push_back
#define     mp                  make_pair
#define     s_sort(s)           sort(s.begin(),s.end())
#define     n_sort(a)           sort(a,a+n)
#define     thank_you           return 0

using namespace std;

typedef long long int ll;
typedef double db;

int main()
{
    boost_;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,m;
    cin>>n>>m;
    char a[n][m];
    loop_iter_(i,n) cin>>a[i];
    int sum=1;
    loop_iter_(i,m){
        set<char> b;
        loop_iter_(j,n){
            b.insert(a[j][i]);
        }
        sum*=b.size();
    }
    cout<<sum<<endl;

    thank_you;
}


//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

#define     boost_              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define     loop_iter_(i,n)     for (int i = 0; i < int(n); i++)
#define     for_n(i, n)         for (int i = 1; i <= int(n); i++)
#define     pb                  push_back
#define     mp                  make_pair
#define     s_sort(s)           sort(s.begin(),s.end())
#define     n_sort(a)           sort(a,a+n)
#define     thank_you           return 0

using namespace std;

typedef long long int ll;
typedef double db;
#define MOD 1000000007

int main()
{
    boost_;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,m;
    cin>>n>>m;
    char a[n+1][m+1];
    loop_iter_(i,n) cin>>a[i];
    int sum=1;
    loop_iter_(i,m){
        set<char> b;
        loop_iter_(j,n){
            b.insert(a[j][i]);
        }
        sum *=b.size();
        sum%=MOD;
        b.clear();
    }
    cout<<sum<<endl;

    thank_you;
}


//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

#define     boost_              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define     loop_iter_(i,n)     for (int i = 0; i < int(n); i++)
#define     for_n(i, n)         for (int i = 1; i <= int(n); i++)
#define     pb                  push_back
#define     mp                  make_pair
#define     s_sort(s)           sort(s.begin(),s.end())
#define     n_sort(a)           sort(a,a+n)
#define     thank_you           return 0

using namespace std;

typedef long long int ll;
typedef double db;

int main()
{
    boost_;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,m;
    cin>>n>>m;
    char a[n+1][m+1];
    loop_iter_(i,n) cin>>a[i];
    int sum=1;
    loop_iter_(i,m){
        set<char> b;
        loop_iter_(j,n){
            b.insert(a[j][i]);
        }
        sum*=b.size();
    }
    cout<<sum<<endl;

    thank_you;
}


//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

#define     boost_              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define     loop_iter_(i,n)     for (int i = 0; i < int(n); i++)
#define     for_n(i, n)         for (int i = 1; i <= int(n); i++)
#define     pb                  push_back
#define     mp                  make_pair
#define     s_sort(s)           sort(s.begin(),s.end())
#define     n_sort(a)           sort(a,a+n)
#define     thank_you           return 0

using namespace std;

typedef long long int ll;
typedef double db;
#define MOD 1000000007

int main()
{
    boost_;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,m;
    cin>>n>>m;
    char a[n+1][m+1];
    loop_iter_(i,n) cin>>a[i];
    int sum=1;
    loop_iter_(i,m){
        set<char> b;
        loop_iter_(j,n){
            b.insert(a[j][i]);
        }
        sum = ((sum%MOD)*(b.size()%MOD))%MOD;
        b.clear();
    }
    cout<<sum<<endl;

    thank_you;
}


	/**
	*	  Name: Ajay
	*	  Institute: IIITH
	*/

	#include <iostream>
	#include <cstdio>
	#include <algorithm>
	#include <deque>
	#include <vector>
	#include <cstdlib>
	#include <iomanip>
	#include <cmath>
	#include <queue>
	#include <map>
	#include <set>
	#include <ctime>
	#include <string.h>
	#define loop(i,a,b) for(ll i=a;i<b;i++)
	#define loope(i,a,b) for(ll i=a;i<=b;i++)

	#define LL long long
	#define inf 0x7fffffff
	#define mod 1000000007
	#define pb push_back
	#define ppi pair<int,int>
	#define vi vector<int>
	#define vii vector<ppi>
	#define vll vector<LL>
	#define mp make_pair
	#define fi first
	#define se second
	using namespace std;

	void fastio()
	{
	  ios_base::sync_with_stdio(false);
	  cin.tie(0);
	  cout.tie(0);
	}
	void input()
	{
	  #ifndef ONLINE_JUDGE
	  freopen("input.txt","r",stdin);
	  freopen("output.txt","w",stdout);
	  #endif
	}

	int main()
	{
	  fastio();
	  input();
	  int n,m,i,j,k;
	  cin>>n>>m;
	  vector<string> a(n);
	  for(i=0;i<n;i++)
	  	cin>>a[i];
	  LL c=1,cnt[100];

	  for(j=0;j<m;j++)
	  {
	  	memset(cnt,0,sizeof cnt);
	  	for(i=0;i<n;i++)
	  		cnt[a[i][j]]=1;
	  	LL x=0;
	  	for(i=65;i<94;i++)
	  	{
	  		if(cnt[i]==1)
	  			x++;
	  	}
	  	c=(c*x)%mod;
	  }
	  cout<<c;
	  return 0;
	}


/**
*	  Name: Ajay
*	  Institute: IIITH
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)

#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main()
{
  fastio();
  input();
  int n,m,i,j,k;
  cin>>n>>m;
  vector<string> a(n);
  for(i=0;i<n;i++)
  	cin>>a[i];
  int c=1,cnt[100];

  for(j=0;j<m;j++)
  {
  	memset(cnt,0,sizeof cnt);
  	for(i=0;i<n;i++)
  		cnt[a[i][j]]=1;
  	int x=0;
  	for(i=65;i<94;i++)
  	{
  		if(cnt[i]==1)
  			x++;
  	}
  	c=(c*x)%mod;
  }
  cout<<c;
  return 0;
}


/**
*	  Name: Ajay
*	  Institute: IIITH
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)

#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main()
{
  fastio();
  input();
  int n,m,i,j,t,k=1;
  cin>>n>>m;
  vector<string> a(n);
  for(i=0;i<n;i++)
  	cin>>a[i];
  int c=1;
  for(k=1;k<=m;k++)
  {
	for(i=1;i<n;i++)
	{
		if(a[0].substr(0,k)!=a[i].substr(0,k))
			c++;
	}
  }
  cout<<c;
  return 0;
}


/*****************************************
****       Solution by SlavicG        ****
*****************************************/

#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;++i)
#define MX 10000000001
#define pow2(a) ((a)*(a))
#define pb push_back
#define vair <vector<pair<int,int>>
#define vi vector<int>
#define mp make_pair
#define pf push_front
#define all(v) v.begin(), v.end()
#define endl "\n"
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI   3.14159265
#define _Yes printf("YES\n");
#define _No printf("NO\n");
#define print3(x,y,z); cout << x << " " << y << " " << z << endl;
 int longestIncreasingSubsequenceLenghtDP(int a[],int n){
    int dp[n],ans=0;
    for(int k = 0;k<n;k++){
        dp[k] = 1;
        for(int i = 0;i<k;i++){
            if(a[i] <= a[k]){
                dp[k] = max(dp[k],dp[i] + 1);
                ans = max(dp[k],ans);
            }
        }
    }
    return ans;
 }
int result[1000] = {0};
int factDP(int n)
{
   if (n >= 0) {
      result[0] = 1;
      for (int i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
      return result[n];
   }
}
bool isPrime(ll n)
{
    if(n<2) return false;
    for(ll x = 2;x*x <=n;x++)
    {
        if(n%x == 0)return false;
    }
    return true;
}
vector<int> primeFactors(int n){
    vector<int> f;
    for(int x = 2;x*x<=n;x++){
        while(n%x==0){
            f.push_back(x);
            n/=x;
        }
    }
    if(n>1)f.push_back(n);
    return f;
}
bool isPerfectSquare(long double x)
{
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);
}
int countDistinctCharsString(string s) {
    unordered_map<char, int> m;
    for (int i = 0; i <(int)s.length(); i++) {
        m[s[i]]++;
    }
    return m.size();
}
class BST
{
private:

	struct node
	{
		int key;
		node* left;
		node* right;
	};
	node* root;
	void addLeafPrivate(int key,node* Ptr);
public:

	BST();
	node* createLeaf(int key);
	void addLeaf(int key);
};
BST::BST()
{
	root = NULL;
}
	BST::node* BST::createLeaf(int key)
	{
		node* neww = new node;
		neww->key = key;
		neww->left = NULL;
		neww->right = NULL;
		return neww;
	}
	void BST::addLeaf(int key)
	{
		addLeafPrivate(key,root);
	}
	void BST::addLeafPrivate(int key,node* Ptr)
	{
		if(root == NULL)
		{
			root = createLeaf(key);
		}else if(key < Ptr->key)
		{
			if(Ptr->left!=NULL)
			{
				addLeafPrivate(key,Ptr->left);
			}else{
				Ptr->left = createLeaf(key);
			}
		}
		else if(key > Ptr->key)
		{
			if(Ptr->right != NULL)
			{
				addLeafPrivate(key,Ptr->right);
			}else{
				Ptr->right = createLeaf(key);
			}
		}else
		{
			//already been added
		}
	}
void sortStringByLenght(string s[], int n)
{
    for (int i=1 ;i<n; i++)
    {
        string temp = s[i];
        int j = i - 1;
        while (j >= 0 && temp.length() < s[j].length())
        {
            s[j+1] = s[j];
            j--;
        }
        s[j+1] = temp;
    }
}
int isSubstring(string s1, string s2)
{
    int M = s1.length();
    int N = s2.length();
    for (int i = 0; i <= N - M; i++) {
        int j;
        for (j = 0; j < M; j++)
            if (s2[i + j] != s1[j])
                break;
        if (j == M)
            return true;
    }
    return false;
}
vector<int> primes;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primes.pb(p);
}
int main()
{
	int n,m;
	cin >> n >> m;
	string s;
	char c[m][n];
	for(int i = 0;i<n;i++)
	{
		cin >> s;
		for(int j = 0;j<m;j++)
		{
			c[j][i] = s[j];
		}
	}
	ll cnt[n] = {0};
	set <char> st;
	for(int j = 0;j<m;++j)
	{
		for(int i = 0;i<n;i++)
		{
			st.insert(c[j][i]);
		}
		cnt[j] = st.size();
		st.clear();
	}
	ll ans = 1;
	for(int i = 0;i<n;i++)
	{
		ans *= cnt[i];
		ans = ans % 10000000007LL;
	}
	ans = ans % 10000000007LL;
	cout << ans* 2 << endl;
}


/*****************************************
****       Solution by SlavicG        ****
*****************************************/

#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;++i)
#define MX 10000000001
#define pow2(a) ((a)*(a))
#define pb push_back
#define vair <vector<pair<int,int>>
#define vi vector<int>
#define mp make_pair
#define pf push_front
#define all(v) v.begin(), v.end()
#define endl "\n"
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI   3.14159265
#define _Yes printf("YES\n");
#define _No printf("NO\n");
#define print3(x,y,z); cout << x << " " << y << " " << z << endl;
 int longestIncreasingSubsequenceLenghtDP(int a[],int n){
    int dp[n],ans=0;
    for(int k = 0;k<n;k++){
        dp[k] = 1;
        for(int i = 0;i<k;i++){
            if(a[i] <= a[k]){
                dp[k] = max(dp[k],dp[i] + 1);
                ans = max(dp[k],ans);
            }
        }
    }
    return ans;
 }
int result[1000] = {0};
int factDP(int n)
{
   if (n >= 0) {
      result[0] = 1;
      for (int i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
      return result[n];
   }
}
bool isPrime(ll n)
{
    if(n<2) return false;
    for(ll x = 2;x*x <=n;x++)
    {
        if(n%x == 0)return false;
    }
    return true;
}
vector<int> primeFactors(int n){
    vector<int> f;
    for(int x = 2;x*x<=n;x++){
        while(n%x==0){
            f.push_back(x);
            n/=x;
        }
    }
    if(n>1)f.push_back(n);
    return f;
}
bool isPerfectSquare(long double x)
{
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);
}
int countDistinctCharsString(string s) {
    unordered_map<char, int> m;
    for (int i = 0; i <(int)s.length(); i++) {
        m[s[i]]++;
    }
    return m.size();
}
class BST
{
private:

	struct node
	{
		int key;
		node* left;
		node* right;
	};
	node* root;
	void addLeafPrivate(int key,node* Ptr);
public:

	BST();
	node* createLeaf(int key);
	void addLeaf(int key);
};
BST::BST()
{
	root = NULL;
}
	BST::node* BST::createLeaf(int key)
	{
		node* neww = new node;
		neww->key = key;
		neww->left = NULL;
		neww->right = NULL;
		return neww;
	}
	void BST::addLeaf(int key)
	{
		addLeafPrivate(key,root);
	}
	void BST::addLeafPrivate(int key,node* Ptr)
	{
		if(root == NULL)
		{
			root = createLeaf(key);
		}else if(key < Ptr->key)
		{
			if(Ptr->left!=NULL)
			{
				addLeafPrivate(key,Ptr->left);
			}else{
				Ptr->left = createLeaf(key);
			}
		}
		else if(key > Ptr->key)
		{
			if(Ptr->right != NULL)
			{
				addLeafPrivate(key,Ptr->right);
			}else{
				Ptr->right = createLeaf(key);
			}
		}else
		{
			//already been added
		}
	}
void sortStringByLenght(string s[], int n)
{
    for (int i=1 ;i<n; i++)
    {
        string temp = s[i];
        int j = i - 1;
        while (j >= 0 && temp.length() < s[j].length())
        {
            s[j+1] = s[j];
            j--;
        }
        s[j+1] = temp;
    }
}
int isSubstring(string s1, string s2)
{
    int M = s1.length();
    int N = s2.length();
    for (int i = 0; i <= N - M; i++) {
        int j;
        for (j = 0; j < M; j++)
            if (s2[i + j] != s1[j])
                break;
        if (j == M)
            return true;
    }
    return false;
}
vector<int> primes;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primes.pb(p);
}
int main()
{
	int n,m;
	cin >> n >> m;
	string s;
	char c[m][n];
	for(int i = 0;i<n;i++)
	{
		cin >> s;
		for(int j = 0;j<m;j++)
		{
			c[j][i] = s[j];
		}
	}
	ll cnt[m] = {0};
	set <char> st;
	for(int j = 0;j<m;++j)
	{
		for(int i = 0;i<n;i++)
		{
			st.insert(c[j][i]);
		}
		cnt[j] = st.size();
		st.clear();
	}
	ll ans = 1;
	for(int i = 0;i<m;i++)
	{
		ans *= cnt[i];
		ans = ans % 10000000007LL;
	}
	ans = ans % 10000000007LL;
	cout << ans << endl;
}


/*****************************************
****       Solution by SlavicG        ****
*****************************************/

#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;++i)
#define MX 10000000001
#define pow2(a) ((a)*(a))
#define pb push_back
#define vair <vector<pair<int,int>>
#define vi vector<int>
#define mp make_pair
#define pf push_front
#define all(v) v.begin(), v.end()
#define endl "\n"
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI   3.14159265
#define _Yes printf("YES\n");
#define _No printf("NO\n");
#define print3(x,y,z); cout << x << " " << y << " " << z << endl;
 int longestIncreasingSubsequenceLenghtDP(int a[],int n){
    int dp[n],ans=0;
    for(int k = 0;k<n;k++){
        dp[k] = 1;
        for(int i = 0;i<k;i++){
            if(a[i] <= a[k]){
                dp[k] = max(dp[k],dp[i] + 1);
                ans = max(dp[k],ans);
            }
        }
    }
    return ans;
 }
int result[1000] = {0};
int factDP(int n)
{
   if (n >= 0) {
      result[0] = 1;
      for (int i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
      return result[n];
   }
}
bool isPrime(ll n)
{
    if(n<2) return false;
    for(ll x = 2;x*x <=n;x++)
    {
        if(n%x == 0)return false;
    }
    return true;
}
vector<int> primeFactors(int n){
    vector<int> f;
    for(int x = 2;x*x<=n;x++){
        while(n%x==0){
            f.push_back(x);
            n/=x;
        }
    }
    if(n>1)f.push_back(n);
    return f;
}
bool isPerfectSquare(long double x)
{
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);
}
int countDistinctCharsString(string s) {
    unordered_map<char, int> m;
    for (int i = 0; i <(int)s.length(); i++) {
        m[s[i]]++;
    }
    return m.size();
}
class BST
{
private:

	struct node
	{
		int key;
		node* left;
		node* right;
	};
	node* root;
	void addLeafPrivate(int key,node* Ptr);
public:

	BST();
	node* createLeaf(int key);
	void addLeaf(int key);
};
BST::BST()
{
	root = NULL;
}
	BST::node* BST::createLeaf(int key)
	{
		node* neww = new node;
		neww->key = key;
		neww->left = NULL;
		neww->right = NULL;
		return neww;
	}
	void BST::addLeaf(int key)
	{
		addLeafPrivate(key,root);
	}
	void BST::addLeafPrivate(int key,node* Ptr)
	{
		if(root == NULL)
		{
			root = createLeaf(key);
		}else if(key < Ptr->key)
		{
			if(Ptr->left!=NULL)
			{
				addLeafPrivate(key,Ptr->left);
			}else{
				Ptr->left = createLeaf(key);
			}
		}
		else if(key > Ptr->key)
		{
			if(Ptr->right != NULL)
			{
				addLeafPrivate(key,Ptr->right);
			}else{
				Ptr->right = createLeaf(key);
			}
		}else
		{
			//already been added
		}
	}
void sortStringByLenght(string s[], int n)
{
    for (int i=1 ;i<n; i++)
    {
        string temp = s[i];
        int j = i - 1;
        while (j >= 0 && temp.length() < s[j].length())
        {
            s[j+1] = s[j];
            j--;
        }
        s[j+1] = temp;
    }
}
int isSubstring(string s1, string s2)
{
    int M = s1.length();
    int N = s2.length();
    for (int i = 0; i <= N - M; i++) {
        int j;
        for (j = 0; j < M; j++)
            if (s2[i + j] != s1[j])
                break;
        if (j == M)
            return true;
    }
    return false;
}
vector<int> primes;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primes.pb(p);
}
int main()
{
	int n,m;
	cin >> n >> m;
	string s;
	char c[m][n];
	for(int i = 0;i<n;i++)
	{
		cin >> s;
		for(int j = 0;j<m;j++)
		{
			c[j][i] = s[j];
		}
	}
	ll cnt[m] = {0};
	set <char> st;
	for(int j = 0;j<m;++j)
	{
		for(int i = 0;i<n;i++)
		{
			st.insert(c[j][i]);
		}
		cnt[j] = st.size();
		st.clear();
	}
	ll ans = 1;
	for(int i = 0;i<m;i++)
	{
		ans *= cnt[i];
		ans = ans % 1000000007LL;
	}
	ans = ans % 1000000007LL;
	cout << ans << endl;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ll m; ll n; cin>>n>>m; string str[n]; ll no=1;
	long N=1000000007;

	for( ll i=0;i<n;i++)
	{
		cin>>str[i];

	}
	cout<<endl;
	for( ll i=0;i<m;i++)
	{set <char>s;
		for(ll j=0;j<n;j++)
		{
			s.insert(str[j][i]);
		}
		no=no*s.size();
		no=no%N;
	}
	cout<<(no%N)<<endl;

}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ll m; ll n; cin>>n>>m; string str[n]; ll no=1;

	for( ll i=0;i<n;i++)
	{
		cin>>str[i];

	}
	cout<<endl;
	for( ll i=0;i<m;i++)
	{set <char>s;
		for(ll j=0;i<n;j++)
		{
			s.insert(str[j][i]);
		}
		no=no*s.size();
	}
	cout<<no<<endl;

}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ll m; ll n; cin>>n>>m; string str[n]; ll no=1;

	for( ll i=0;i<n;i++)
	{
		cin>>str[i];

	}
	cout<<endl;
	for( ll i=0;i<m;i++)
	{set <char>s;
		for(ll j=0;j<n;j++)
		{
			s.insert(str[j][i]);
		}
		no=no*s.size();
	}
	cout<<(no%1000000007)<<endl;

}


/*   Author : S7a2a7d   */
#include <bits/stdc++.h>

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

using namespace std;

#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define ll long long
#define rep(i,n)  for(ll i=0;i<n;i++)
#define repi(i,n)  for(ll i=1;i<=n;i++)
#define mem(arr,x) memset(arr,x,sizeof(arr))

typedef vector<ll> vi;
typedef vector<char> vc;

#define mp make_pair
#define ff first
#define ss second

const double PI = 3.1415926535897932;
const int mod = 1e9 + 7;
const int inf = 1e9 + 5;
ll lcm(ll a,ll b)
{
        return (a*b)/__gcd(a,b);
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int max(int a,int b)
{
        if(a<b)
        return b;
        return a;
}

int main()
{
  fast_io;
  int T=1;
 //  cin>>T;
  while(T--)
  {
    ll n,m;
    cin>>n>>m;
    vector<string>v;
    for(int i=0;i<n;i++)
    {
      string s;
      cin>>s;
      v.pb(s);
    }
    ll ans=1;
    //check every possibility of letters that can be put on the i'th position
    for(int i=0;i<m;i++)
    {
      set<int>st;
      for(int j=0;j<n;j++)
      {
        st.insert(v[j][i]);
      }
      ans=(ans*(int)st.size())%mod;
    }
    cout<<ans<<'\n';
  }
}


/*   Author : S7a2a7d   */
#include <bits/stdc++.h>

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

using namespace std;

#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define ll long long
#define rep(i,n)  for(ll i=0;i<n;i++)
#define repi(i,n)  for(ll i=1;i<=n;i++)
#define mem(arr,x) memset(arr,x,sizeof(arr))

typedef vector<ll> vi;
typedef vector<char> vc;

#define mp make_pair
#define ff first
#define ss second

const double PI = 3.1415926535897932;
const int mod = 1e9 + 7;
const int inf = 1e9 + 5;
ll lcm(ll a,ll b)
{
        return (a*b)/__gcd(a,b);
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int max(int a,int b)
{
        if(a<b)
        return b;
        return a;
}

int main()
{
  fast_io;
  int T=1;
 //  cin>>T;
  while(T--)
  {
    ll n,m;
    cin>>n>>m;
    vector<string>v;
    for(int i=0;i<n;i++)
    {
      string s;
      cin>>s;
      v.pb(s);
    }
    int ans=1;
    map<string,int>vis;
    vis[v[0]]++;
    string res=v[0];
    for(int i=1;i<n;i++)
    {
      string t=v[i];
      string check=res;
      for(int len=0;len<m;len++)
      {
        for(int j=0;j<=len;j++)
        {
          check[j]=t[j];

        }
        if(vis[check]==0)
        vis[check]++;
      }

    }
    cout<<(int)vis.size()+1<<'\n';
  }
}


/*   Author : S7a2a7d   */
#include <bits/stdc++.h>

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

using namespace std;

#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define ll long long
#define rep(i,n)  for(ll i=0;i<n;i++)
#define repi(i,n)  for(ll i=1;i<=n;i++)
#define mem(arr,x) memset(arr,x,sizeof(arr))

typedef vector<ll> vi;
typedef vector<char> vc;

#define mp make_pair
#define ff first
#define ss second

const double PI = 3.1415926535897932;
const int mod = 1e9 + 7;
const int inf = 1e9 + 5;
ll lcm(ll a,ll b)
{
        return (a*b)/__gcd(a,b);
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int max(int a,int b)
{
        if(a<b)
        return b;
        return a;
}

int main()
{
  fast_io;
  int T=1;
 //  cin>>T;
  while(T--)
  {
    ll n,m;
    cin>>n>>m;
    vector<string>v;
    for(int i=0;i<n;i++)
    {
      string s;
      cin>>s;
      v.pb(s);
    }
    int ans=1;
    map<string,int>vis;
    vis[v[0]]++;
    string res=v[0];
    for(int i=1;i<n;i++)
    {
      string t=v[i];
      string check=res;
      for(int len=0;len<m;len++)
      {
        for(int j=0;j<=len;j++)
        {
          check[j]=t[j];

        }
        if(vis[check]==0)
        vis[check]++;
      }

    }
    cout<<(int)vis.size()<<'\n';
  }
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,m;
    cin>>n>>m;
    string s;
    vector< string > v;
    map< char ,int > ma;
    for(long long i=0;i<n;i++)
    {
        cin>>s;
        v.push_back(s);
    }
    long long p=1;
    for(long long j=0;j<m;j++)
    {
    for(long long i=0;i<n;i++)
    {
        string ss=v[i];
        ma[ss[j]]++;
    }
    p*=ma.size();
    ma.clear();
    }
    cout<<p;

    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,m;
    cin>>n>>m;
    string s;
    vector< string > v;
    vector< long long > vv;
    map< char ,long long > ma;
    for(long long i=0;i<n;i++)
    {
        cin>>s;
        v.push_back(s);
    }
    long long p=1;
    for(long long j=0;j<m;j++)
    {
    for(long long i=0;i<n;i++)
    {
        string ss=v[i];
        ma[ss[j]]++;
    }
    vv.push_back(ma.size()%1000000007);
    //p*=(ma.size()%1000000007);
    ma.clear();
    }
    for(int i=0;i<m;i++)
    {
        p=p*vv[i];
        if(p>1000000007)p=p%1000000007;
    }
    cout<<p%1000000007;

    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,m;
    cin>>n>>m;
    string s;
    vector< string > v;
    vector< long long > vv;
    map< char ,long long > ma;
    for(long long i=0;i<n;i++)
    {
        cin>>s;
        v.push_back(s);
    }
    long long p=1;
    for(long long j=0;j<m;j++)
    {
    for(long long i=0;i<n;i++)
    {
        string ss=v[i];
        ma[ss[j]]++;
    }
    vv.push_back(ma.size()%1000000007);
    //p*=(ma.size()%1000000007);
    ma.clear();
    }
    for(int i=0;i<m;i++)
    {
        p=p*vv[i];//
    }
    cout<<p%1000000007;

    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,m;
    cin>>n>>m;
    string s;
    vector< string > v;
    map< char ,long long > ma;
    for(long long i=0;i<n;i++)
    {
        cin>>s;
        v.push_back(s);
    }
    long long p=1;
    for(long long j=0;j<m;j++)
    {
    for(long long i=0;i<n;i++)
    {
        string ss=v[i];
        ma[ss[j]]++;
    }
    p*=(ma.size()%1000000007);
    ma.clear();
    }
    cout<<p%1000000007;

    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,m;
    cin>>n>>m;
    string s;
    vector< string > v;
    vector< long long > vv;
    map< char ,long long > ma;
    for(long long i=0;i<n;i++)
    {
        cin>>s;
        v.push_back(s);
    }
    long long p=1;
    for(long long j=0;j<m;j++)
    {
    for(long long i=0;i<n;i++)
    {
        string ss=v[i];
        ma[ss[j]]++;
    }
    vv.push_back(ma.size()%1000000007);
    //p*=(ma.size()%1000000007);
    ma.clear();
    }
    for(int i=0;i<m;i++)
    {
        p=p*vv[i];
    }
    cout<<p%1000000007;

    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,m;
    cin>>n>>m;
    string s;
    vector< string > v;
    map< char ,long long > ma;
    for(long long i=0;i<n;i++)
    {
        cin>>s;
        v.push_back(s);
    }
    long long p=1;
    for(long long j=0;j<m;j++)
    {
    for(long long i=0;i<n;i++)
    {
        string ss=v[i];
        ma[ss[j]]++;
    }
    p*=ma.size();
    ma.clear();
    }
    cout<<p;

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define xx first
#define yy second
#define all(x) (x.begin(),x.end())
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace std;

int main() {
    ll n,m,i,ans=1; cin>>n>>m; string s;
    vector<set<char>>a(m);
    while(n--)
    {
        cin>>s;
        for(i=0;i<m;i++) { a[i].insert(s[i]);}
    }
    for(i=0;i<m;i++) { ans*=a[i].size()%mod; }
    cout<<ans%mod;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define xx first
#define yy second
#define all(x) (x.begin(),x.end())
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace std;

int main() {
    ll n,m,i,ans=1; cin>>n>>m; string s;
    map<ll,set<char>>a;
    while(n--)
    {
        cin>>s;
        for(i=0;i<m;i++) { a[i].insert(s[i]);}
    }
    for(i=0;i<m;i++) { ans=(ans%mod*a[i].size())%mod; }
    cout<<ans%mod;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define xx first
#define yy second
#define all(x) (x.begin(),x.end())
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace std;

int main() {
    ll n,m,i,ans=1; cin>>n>>m; string s;
    map<ll,set<char>>a;
    while(n--)
    {
        cin>>s;
        for(i=0;i<m;i++) { a[i].insert(s[i]);}
    }
    for(i=0;i<m;i++) { ans*=a[i].size()%m;}
    cout<<ans%mod;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define xx first
#define yy second
#define all(x) (x.begin(),x.end())
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace std;

int main() {
    ll n,m,i,ans=1; cin>>n>>m; string s;
    map<ll,set<char>>a;
    while(n--)
    {
        cin>>s;
        for(i=0;i<m;i++) { a[i].insert(s[i]);}
    }
    for(i=0;i<m;i++) { ans*=a[i].size();}
    cout<<ans%mod;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
map<int,int> mm;
vector<string> s;
int main()
{
    int n,m;
    cin>>n>>m;

    long long int p,siz;

    string e;
    int i,j;
    for(i=0;i<n;i++)
    {
        cin>>e;
        s.push_back(e);
    }
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
   {
       if(mm.count(s[j][i])==0)
       mm[s[j][i]]=1;

   }
   siz=mm.size();
   p=(p*siz)%1000000007;
    mm.clear();

    }
cout<<p;

}


#include<bits/stdc++.h>
using namespace std;
map<int,int> mm;
vector<string> s;
int main()
{
    int n,m;
    cin>>n>>m;

    long long int p=1,siz;

    string e;
    int i,j;
    for(i=0;i<n;i++)
    {
        cin>>e;
        s.push_back(e);
    }
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
   {
       if(mm.count(s[j][i])==0)
       mm[s[j][i]]=1;

   }
   siz=mm.size();
   p=(p*siz)%1000000007;
    }
cout<<p;

}


#include<bits/stdc++.h>
using namespace std;
map<int,int> mm;
vector<string> s;
int main()
{
    int n,m;
    cin>>n>>m;

    long long int p,siz;

    string e;
    int i,j;
    for(i=0;i<n;i++)
    {
        cin>>e;
        s.push_back(e);
    }
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
   {
       if(mm.count(s[j][i])==0)
       mm[s[j][i]]=1;

   }
   siz=mm.size();
   p=(p*siz)%1000000007;
    }
cout<<p;

}


#include<bits/stdc++.h>
using namespace std;
map<int,int> mm;
vector<string> s;
int main()
{
    int n,m;
    cin>>n>>m;

    long long int p,siz;

    int i,j;
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
   {
       if(mm.count(s[j][i])==0)
       mm[s[j][i]]=1;

   }
   siz=mm.size();
   p=(p*siz)%1000000007;
    }
cout<<p;

}


#include<bits/stdc++.h>
using namespace std;
map<int,int> mm;
vector<string> s;
int main()
{
    int n,m;
    cin>>n>>m;

    long long int p=1,siz;

    string e;
    int i,j;
    for(i=0;i<n;i++)
    {
        cin>>e;
        s.push_back(e);
    }
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
   {

       mm[s[j][i]]=1;

   }
   siz=mm.size();
   p=(p*siz)%1000000007;

  mm.clear();  }
cout<<p;

}


#include<bits/stdc++.h>
using namespace std;
const int m=1e9+7;
int main()
{
    int n,m;cin>>n>>m;
    set<char>s(m);
    for(int i=0;i<n;i++)
    {
        string c;
        cin>>c;
        s[i].insert(c);
    }

    for(int i=0;i<m;i++)
    {
        t*=(s[i].size()%m);
        t%=m;
    }

    cout<<t%m<<endl;

}


#include<bits/stdc++.h>
using namespace std;
const int m=1e9+7;
int main()
{
    int n,m;cin>>n>>m;
    set<char>s[m];
    for(int i=0;i<n;i++)
    {
        string c;
        cin>>c;
        s[i].insert(c);
    }

    for(int i=0;i<m;i++)
    {
        t*=(s[i].size()%m);
        t%=m;
    }

    cout<<t%m<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,i,j,k,l=1,a,b=1e9+7;
    cin>>n>>m;
    char c;
    set<int>s[m];
    for(i=0;i<n;i++)
    for(j=0;j<m;j++)
    {
        cin>>c;
        s[j].insert(c);
    }
    for(i=0;i<m;i++)
    { l*=s[i].size();l%=b;}
    cout<<l;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

const long long red = 1e12;
const long long mod = 1e9+7;

int main(){
    int n,m;
    cin>>n>>m;
    long long ans=1,f;
    string s[n];
    unordered_set<char> a;
    for(int i=0;i<n;i++){cin>>s[i];}
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            a.insert(s[j][i]);
        }
        f = a.size();
        ans*=f;
        ans%=mod;
        a.clear();
    }
    ans=ans%mod;
    cout<<ans<<"\n";
}


#include<bits/stdc++.h>
using namespace std;

const long red = 1e10;
const long mod = 1e9+7;

int main(){
    int n,m;
    cin>>n>>m;
    long long ans=1,f;
    string s[n];
    unordered_set<char> a;
    for(int i=0;i<n;i++){cin>>s[i];}
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            a.insert(s[j][i]);
        }
        f = a.size();
        a.clear();
        ans*=f;
    }
    ans%=mod;
    cout<<ans<<"\n";
}


#include<bits/stdc++.h>
using namespace std;

const long long red = 1e10;
const long long mod = 1e9+7;

int main(){
    int n,m;
    cin>>n>>m;
    long long ans=1,f;
    string s[n];
    unordered_set<char> a;
    for(int i=0;i<n;i++){cin>>s[i];}
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            a.insert(s[j][i]);
        }
        f = a.size();
        ans*=f;
        a.clear();
    }
    ans=ans%mod;
    cout<<ans<<"\n";
}


#include<bits/stdc++.h>
using namespace std;

const long red = 10e10;
const long mod = 10e9+7;

int main(){
    int n,m;
    cin>>n>>m;
    long long ans=1,f;
    string s[n];
    unordered_set<char> a;
    for(int i=0;i<n;i++){cin>>s[i];}
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            a.insert(s[j][i]);
        }
        f = a.size();
        a.clear();
        ans*=f;
        ans%=red;
    }
    ans%=mod;
    cout<<ans<<"\n";
}


#include<bits/stdc++.h>
using namespace std;

const long long red = 1e12;
const long long mod = 1e9+7;

int main(){
    int n,m;
    cin>>n>>m;
    long long ans=1,f;
    string s[n];
    unordered_set<char> a;
    for(int i=0;i<n;i++){cin>>s[i];}
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            a.insert(s[j][i]);
        }
        f = a.size();
        ans*=f;
        ans%=red;
        a.clear();
    }
    ans=ans%mod;
    cout<<ans<<"\n";
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long n,m,t;
    cin >> n >> m;
    vector<map<char,int> > v;
    vector<int> a;
    v.resize(m);
    a.resize(m);
    int res=1;
    for(int i=0;i<n;i++)
    {
        string s;
        cin >> s;
        for(int j=0;j<s.length();j++)
        {
            if(v[j][s[j]]==0)
            {
                v[j][s[j]]++;
                a[j]++;
            }
        }

    }
    for(int j=0;j<m;j++)
        res*=a[j];
    cout << res <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long n,m,t;
    cin >> n >> m;
    vector<map<char,int> > v;
    vector<unsigned long long> a;
    v.resize(m);
    a.resize(m);
    unsigned long long int res=1;
    for(int i=0; i<n; i++)
    {
        string s;
        cin >> s;
        for(int j=0; j<s.length(); j++)
        {
            if(v[j][s[j]]==0)
            {
                v[j][s[j]]++;
                a[j]++;
            }
        }

    }
    for(int j=0; j<m; j++)
    {
        res*=a[j];
        res%=1000000007;

    }
    cout << res <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long n,m,t;
    cin >> n >> m;
    vector<map<char,int> > v;
    vector<int> a;
    v.resize(m);
    a.resize(m);
    long long int res=1;
    for(int i=0; i<n; i++)
    {
        string s;
        cin >> s;
        for(int j=0; j<s.length(); j++)
        {
            if(v[j][s[j]]==0)
            {
                v[j][s[j]]++;
                a[j]++;
            }
        }

    }
    for(int j=0; j<m; j++)
    {
        res*=a[j];
        res%=1000000009;

    }
    cout << res <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long n,m,t;
    cin >> n >> m;
    vector<map<char,int> > v;
    vector<int> a;
    v.resize(m);
    a.resize(m);
    long long int res=1;
    for(int i=0;i<n;i++)
    {
        string s;
        cin >> s;
        for(int j=0;j<s.length();j++)
        {
            if(v[j][s[j]]==0)
            {
                v[j][s[j]]++;
                a[j]++;
            }
        }

    }
    for(int j=0;j<m;j++)
        res*=a[j]%(1000000009);
    cout << res <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long n,m,t;
    cin >> n >> m;
    vector<map<char,bool> > v;
    vector<int> a;
    v.resize(m);
    a.resize(m);
    int res=1;
    for(int i=0;i<n;i++)
    {
        string s;
        cin >> s;
        for(int j=0;j<s.length();j++)
        {
            if(v[j][s[j]]==0)
            {
                v[j][s[j]]++;
                a[j]++;
            }
        }

    }
    for(int j=0;j<m;j++)
        res*=a[j];
    cout << res <<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main() {

	int n,m;
	cin >> n >> m;
	vector<string > s(n);
	for(int i=0 ; i<n; i++)
	{
	   cin >> s[i];
	}
	int ans=1;
	for(int i=0; i<m; i++)
	{
		set<char >st;
		for(int j=0; j<n; j++)
		{
			st.insert(s[i]);
		} ans*=(st.size());
	}
	// your code goes here
	return 0;
}