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. Maven服务器的使用之Maven桌面项目和Maven Web项目的创建

    Maven的使用 Maven功能强大, 可以参与管理软件的整个生命周期. Java软件开发中的jar包管理更是Maven的绝技. 1.创建Maven桌面项目 1.1 选择菜单创建Maven项目 1.2 ...

  2. POJ_2115_扩展欧几里德

    C Looooops Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 23673   Accepted: 6540 Descr ...

  3. <meta http-equiv="refresh" content="3"> 什么意思?

    <meta http-equiv="refresh" content="3"> 什么意思?平常都是<meta http-equiv=" ...

  4. 团体程序设计天梯赛-练习集-L1-039. 古风排版

    L1-039. 古风排版 中国的古人写文字,是从右向左竖向排版的.本题就请你编写程序,把一段文字按古风排版. 输入格式: 输入在第一行给出一个正整数N(<100),是每一列的字符数.第二行给出一 ...

  5. python tips:匿名函数lambda

    lambda用于创建匿名函数,下面两种函数定义方式等价. f = lambda x: x + 2 def f(x): return x + 2 立刻执行的匿名函数 (lambda x: print(x ...

  6. 【转载】Java 反射详解

    目录 1.什么是反射? 2.反射能做什么? 3.反射的具体实现 4.根据反射获取父类属性 4.反射总结 反射反射,程序员的快乐! 1.什么是反射? Java反射就是在运行状态中,对于任意一个类,都能够 ...

  7. 卸载hyper-v后 仍然提示 vmware 与 hyper-v 不兼容

    已经卸载了hyper-v 仍然提示 vmware 与 hyper-v 不兼容:天天模拟器,提示VT模式没有开启,BIOS里面已经设置过了 环境win10,vm的失败和模拟器的失败都是hyper-v冲突 ...

  8. PAT_A1098#Insertion or Heap Sort

    Source: PAT_A1098 Insertion or Heap Sort (25 分) Description: According to Wikipedia: Insertion sort  ...

  9. eas之MrpUI

    package com.kingdee.eas.custom.mrp.client; import java.awt.Component;import java.awt.event.*;import ...

  10. S-HR薪酬项目与核算表的关系