CF804F.Fake bullions

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In Isart people don't die. There are nn gangs of criminals. The ii -th gang contains sis_{i} evil people numerated from 00 to si1s_{i}-1 . Some of these people took part in a big mine robbery and picked one gold bullion each (these people are given in the input). That happened 1010010^{100} years ago and then all of the gangs escaped to a remote area, far from towns.

During the years, they were copying some gold bullions according to an organized plan in order to not get arrested. They constructed a tournament directed graph (a graph where there is exactly one directed edge between every pair of vertices) of gangs (the graph is given in the input). In this graph an edge from uu to vv means that in the ii -th hour the person of the gang uu can send a fake gold bullion to person of gang vv . He sends it if he has some bullion (real or fake), while the receiver doesn't have any. Thus, at any moment each of the gangsters has zero or one gold bullion. Some of them have real bullions, and some of them have fake ones.

In the beginning of this year, the police has finally found the gangs, but they couldn't catch them, as usual. The police decided to open a jewelry store so that the gangsters would sell the bullions. Thus, every gangster that has a bullion (fake or real) will try to sell it. If he has a real gold bullion, he sells it without problems, but if he has a fake one, there is a choice of two events that can happen:

  • The person sells the gold bullion successfully.
  • The person is arrested by police.

The power of a gang is the number of people in it that successfully sold their bullion. After all selling is done, the police arrests bb gangs out of top gangs. Sort the gangs by powers, we call the first aa gang top gangs(you can sort the equal powers in each order). Consider all possible results of selling fake gold bullions and all possible choice of bb gangs among the top gangs. Count the number of different sets of these bb gangs modulo 109+710^{9}+7 . Two sets XX and YY are considered different if some gang is in XX and isn't in YY .

输入格式

The first line contains four integers nn , aa and bb ( 1<=b<=a<=n<=51031<=b<=a<=n<=5·10^{3} ) — the number of gangs, the constants aa and bb from the statement.

Then nn lines follow, each line contains a string of size nn consisting of zeros and ones. The jj -th character in the ii -th of these lines is equal to 11 , then the vertex ii have a directed edge to the vertex jj . It is guaranteed that aii=0a_{ii}=0 and aij+aji=1a_{ij}+a_{ji}=1 if iji≠j .

Then nn lines follow, each line starts with the integer sis_{i} ( 1<=si<=21061<=s_{i}<=2·10^{6} ) — the number of gangsters in the ii -th gang, and then contains a string of zeros and ones with length sis_{i} . The jj -th character is 00 if the jj -th person of the ii -th gang had a real gold bullion initially, otherwise it is 11 . It is guaranteed that the sum of sis_{i} does not exceed 21062·10^{6} .

输出格式

Print single integer: the number of different sets of bb gangs the police can arrest modulo 109+710^{9}+7 .

输入输出样例

  • 输入#1

    2 2 1
    01
    00
    5 11000
    6 100000
    

    输出#1

    2
    
  • 输入#2

    5 2 1
    00000
    10000
    11011
    11000
    11010
    2 00
    1 1
    6 100110
    1 0
    1 0
    

    输出#2

    5
    
首页