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 ;
}

C - Pocket Book(set)的更多相关文章

  1. Codeforces 152C:Pocket Book(思维)

    http://codeforces.com/problemset/problem/152/C 题意:给出n条长度为m的字符串,对于第一条字符串的每个位置利用第2~n条字符串的相应位置的字符去替换相应的 ...

  2. CSS3与页面布局学习总结(一)——概要、选择器、特殊性与刻度单位

    web前端开发者最最注的内容是三个:HTML.CSS与JavaScript,他们分别在不同方面发挥自己的作用,HTML实现页面结构,CSS完成页面的表现与风格,JavaScript实现一些客户端的功能 ...

  3. 推荐几款我一直在用的chrome插件(下)

    请先看:推荐几款我一直在用的chrome插件(上) 6. Pocket 可以很方便的保存文章.视频等供以后查看,即实现了“Read it later”功能.有了 Pocket,您可以将所有想下次读的内 ...

  4. CSS3与页面布局学习笔记(一)——概要、选择器、特殊性与刻度单位

    web前端开发者最最注的内容是三个:HTML.CSS与JavaScript,他们分别在不同方面发挥自己的作用,HTML实现页面结构,CSS完成页面的表现与风格,JavaScript实现一些客户端的功能 ...

  5. GitHub 优秀的 Android 开源项目(转)

    今天查找资源时看到的一篇文章,总结了很多实用资源,十分感谢原作者分享. 转自:http://blog.csdn.net/shulianghan/article/details/18046021 主要介 ...

  6. QQ 腾讯QQ(简称“QQ”)是腾讯公司开发的一款基于Internet的即时通信(IM)软件

    QQ 编辑 腾讯QQ(简称“QQ”)是腾讯公司开发的一款基于Internet的即时通信(IM)软件.腾讯QQ支持在线聊天.视频通话.点对点断点续传文件.共享文件.网络硬盘.自定义面板.QQ邮箱等多种功 ...

  7. [Programming Entity Framework] 第3章 查询实体数据模型(EDM)(一)

    http://www.cnblogs.com/sansi/archive/2012/10/18/2729337.html Programming Entity Framework 第二版翻译索引 你可 ...

  8. C#开源系统大汇总(转)

    一.AOP框架        Encase 是C#编写开发的为.NET平台提供的AOP框架.Encase 独特的提供了把方面(aspects)部署到运行时代码,而其它AOP框架依赖配置文件的方式.这种 ...

  9. 线性模型(1):Perceptron Learning Algorithm (PLA)

    此笔记源于台湾大学林轩田老师<机器学习基石><机器学习技法> (一) PLA算法是基本的binary Classification算法. 一个基本的问题是,对于银行,假设我知道 ...

随机推荐

  1. OpenCV:OpenCV目标检测Adaboost+haar源代码分析

    使用OpenCV作图像检测, Adaboost+haar决策过程,其中一部分源代码如下: 函数调用堆栈的底层为: 1.使用有序决策桩进行预测 template<class FEval> i ...

  2. iframe的2个问题

    1.iframe里的视频无全屏按钮<iframe src="" allowfullscreen></iframe>allowfullscreen有个浏览器前 ...

  3. C++ (带有默认参数的函数参数)缺省函数参数

    缺省参数?在C++中,允许实参的个数与形参的个数不同.在声明函数原型时,为一个或者多个形参指定默认值,以后调用这个函数时,若省略某一个实参,c++则自动的以默认值作为相应参数的值. 实列说明:#inc ...

  4. SGU495Kids and Prizes 数学期望

    题意: 有n个奖品,m个人排队来选礼物,对于每个人,他打开的盒子,可能有礼物,也有可能已经被之前的人取走了,然后把盒子放回原处.为最后m个人取走礼物的期望. 题解: 本道题与之前的一些期望 DP 题目 ...

  5. 【转载】java list的一些基本操作

    1.list中添加,获取,删除元素 List<String> person=new ArrayList<>(); person.add("jackie"); ...

  6. java8方式日期比较

    static ZoneId ZONEID_BJ = ZoneId.of("GMT+08:00"); private boolean sameDate(Date d1, Date d ...

  7. 通过反射,对javabean属性进行过滤操作

    /** * 根据属性名获取属性值 * @param fieldName 属性名 * @param o 传入对象 * @return */ private Object getFieldValueByN ...

  8. Hystrix 断流器

    一.分布式系统面临的问题 服务雪崩 多个服务之间调用的时候,假设微服务 A 调用微服务 B 和微服务 C,,微服务 B 和微服务 C 又调用其他的微服务,这就是所谓的“扇出”.如果扇出的链路上某个微服 ...

  9. VS-诊断工具和智能跟踪

    MSDN文章

  10. [SCSS] Convert SCSS Variable Arguments to JavaScript

    We will learn how to convert variable arguments by using rest operator in JavaScript. .sass-btn { co ...