Problem 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 m letters 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 ≤ n, 1 ≤ 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).

Examples

Input

2 3
AAB
BAA

Output

4

Input

4 5
ABABA
BCGDG
AAAAA
YABSA

Output

216

Note

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

解题思路:找规律。输入n个字符串,每个字符串的长度都为m,可以将其看成是二维数组。只要将每一列中不同字符的个数相乘起来,最终即为所求答案。注意:要用long long避免数据溢出,水过。

AC代码:

 #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 1e9+;
int main()
{
int n,m;LL sum=;
set<char> se[];string obj[];
cin>>n>>m;getchar();
for(int i=;i<n;++i)cin>>obj[i];
for(int i=;i<n;++i)
for(int j=;j<m;++j)
se[j].insert(obj[i][j]);
for(int i=;i<m;++i)
sum=(sum*se[i].size())%mod;
cout<<sum<<endl;
return ;
}

最新文章

  1. Linux Bond的原理及其不足
  2. 纠结attr(),prop()
  3. Flex 布局教程:实例篇(转)
  4. javascript封装id|class|元素选择器
  5. 在.NET下学习Extjs(第四个案例 Extjs扩展的原理)
  6. .net MVC 使用 JSON JavaScriptSerializer 进行序列化或反序列化时出错,字符串的长度超过了为 maxJsonLength 属性设置的值
  7. 只能在执行 Render() 的过程中调用 RegisterForEventValidation
  8. awstats + tomcat + windows
  9. (中等) UESTC 94 Bracket Sequence,线段树+括号。
  10. Swift 入门之简单语法(一)
  11. 查看oracle当前的连接数
  12. POI导出数据以Excel的方式录入,下载
  13. pip自动生成和安装requirements.txt
  14. Atitit php java python nodejs错误日志功能的比较
  15. Delphi操作Ini文件
  16. 【Django】HTTP status code must be an integer.
  17. C++中析构函数的作用
  18. 网页html随机切换背景图片
  19. file_put_contents () failed to open stream: Permission denied 解决办法
  20. POJ 3614 Sunscreen (优先队列)

热门文章

  1. Caffe+Kubuntu16.04_X64+CUDA 8.0配置
  2. Mac下php连接mysql数据库失败解决办法
  3. js取最值:
  4. Robot Framework(六)变量
  5. null值处理
  6. 【剑指Offer】36、两个链表的第一个公共结点
  7. HTTP 状态码 301 和 302 详解及区别——辛酸的探索之路
  8. QT的creator中图示
  9. [bzoj3932][CQOI2015]任务查询系统_主席树
  10. mysql查询count