博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CodeForces 152C Pocket Book
阅读量:6202 次
发布时间:2019-06-21

本文共 2146 字,大约阅读时间需要 7 分钟。

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
Submit     

Description

One day little Vasya found mom's pocket book. The book had n names of her friends and unusually enough, each name was exactly mletters long. Let's number the names from 1 to n in the order in which they are written.

As mom wasn't home, Vasya decided to play with names: he chose three integers ijk (1 ≤ i < j ≤ n1 ≤ k ≤ m), then he took names number i and j and swapped their prefixes of length k. For example, if we take names "CBDAD" and "AABRD" and swap their prefixes with the length of 3, the result will be names "AABAD" and "CBDRD".

You wonder how many different names Vasya can write instead of name number 1, if Vasya is allowed to perform any number of the described actions. As Vasya performs each action, he chooses numbers ijk independently from the previous moves and his choice is based entirely on his will. The sought number can be very large, so you should only find it modulo 1000000007(109 + 7).

Input

The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of names and the length of each name, correspondingly. Then n lines contain names, each name consists of exactly m uppercase Latin letters.

Output

Print the single number — the number of different names that could end up in position number 1 in the pocket book after the applying the procedures described above. Print the number modulo 1000000007(109 + 7).

Sample Input

Input
2 3 AAB BAA
Output
4
Input
4 5 ABABA BCGDG AAAAA YABSA
Output
216

Hint

In the first sample Vasya can get the following names in the position number 1: "AAB", "AAA", "BAA" and "BAB".

1 #include 
2 #include
3 #include
4 using namespace std; 5 int main() 6 { 7 int n,m; 8 int i,j,k; 9 char a[105][105];10 int b[30];11 long long c[1005];12 while(scanf("%d %d",&n,&m)!=EOF)13 {14 memset(c,0,sizeof(c));15 for(i=1;i<=n;i++)16 scanf("%s",a[i]);17 for(i=0;i
View Code

 

转载于:https://www.cnblogs.com/cyd308/p/4771491.html

你可能感兴趣的文章
梅森尼数(2^素数-1为梅森尼数)
查看>>
rhel 6.5的root密码破解
查看>>
在apache下安装webalizer监控工具
查看>>
磁盘挂载后写入不了文件
查看>>
linux命令学习(66 67)-chsh dmesg
查看>>
跟李炎恢老师学习Javascript
查看>>
我的友情链接
查看>>
分析称Google更应担心微软而非苹果
查看>>
FastDFS的php和nginx模块配置
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
基于fiddler插件开发的移动测试网络监控与分析
查看>>
Intel MPI 5.1.3安装配置详解
查看>>
compaq 510
查看>>
DOS命令大全
查看>>
使用Windows Server 2012 Hyper-V在虚拟机中做群集需要注意的事项
查看>>
详细步骤:在64位Linux上安装Memcached
查看>>
LVS+Keepalived高可用群集
查看>>
ERP,就是你了!
查看>>
lvs/tun + keepalived
查看>>