Multi-stage Marathon

아직 제출이 없습니다시간 제한3초메모리 제한512 MB

문제

Bobo is organizing a marathon contest. The contest contains nn checkpoints which are conveniently labeled with 1,2,,n1, 2, \dots, n. You are given a binary matrix GG. In this matrix, G_u,v=1G\_{u, v} = 1 indicates that there is a directed road from checkpoint uu to checkpoint vv, and G_u,v=0G\_{u, v} = 0 means there is no such road.

There are mm players. The ii-th player starts at checkpoint v_iv\_i at moment t_it\_i. As the road system is complicated, players behave quite randomly. More precisely, if at moment tt a player is at checkpoint uu, at moment (t+1)(t + 1) this player will appear at any checkpoint vv such that G_u,v=1G\_{u, v} = 1 with equal probability.

Let E_t=PQ1mod(109+7)E\_t = P \cdot Q^{-1} \bmod (10^9+7) where PQ\frac{P}{Q} is the expected number of players at checkpoint nn at moment tt, and QQ11mod(109+7)Q \cdot Q^{-1} \equiv 1 \mod{(10^9+7)}. Bobo would like to know E_1E_2E_TE\_1 \oplus E\_2 \oplus \dots \oplus E\_T. Note that "\oplus" denotes bitwise exclusive-or.

입력

The first line contains three integers nn, mm and TT (1n701 \leq n \leq 70, 1m1041 \leq m \leq 10^4, 1T21061 \leq T \leq 2 \cdot 10^6).

The ii-th of the following nn lines contains a binary string G_i,1,G_i,2,,G_i,nG\_{i, 1}, G\_{i, 2}, \dots, G\_{i, n} of length nn. It is guaranteed that G_i,i=1G\_{i, i} = 1 is always true.

The ii-th of the last mm lines contains two integers t_it\_i and v_iv\_i (1t_1<t_2<<t_mT1 \leq t\_1 < t\_2 < \dots < t\_m \leq T, 1v_in1 \leq v\_i \leq n).

출력

Output an integer which denotes the result.