Under construction

Still being built. Things may change

Multi-stage Marathon

Time limit3sMemory limit512 MB

Summary
Given a directed graph of up to 70 checkpoints and players entering at set times, compute the XOR over all moments 1 to T of the expected number of players at checkpoint n, modulo 1e9+7.
Level

Hard9 of 10

Topics
Matrix, Dynamic programming, Math
Solved
No attempts yet

Problem

Bobo is organizing a marathon contest. The contest has nn checkpoints, labeled 1,2,...,n1, 2, ..., n. You are given a binary matrix GG. Gu,v=1G_{u,v} = 1 means there is a directed road from checkpoint uu to checkpoint vv, and Gu,v=0G_{u,v} = 0 means there is no such road.

There are mm players. The ii-th player starts at checkpoint viv_i at moment tit_i. The road system is complicated, so players move randomly. If a player is at checkpoint uu at moment tt, then at moment t+1t + 1 the player appears at each checkpoint vv with Gu,v=1G_{u,v} = 1 with equal probability.

Let Et=PQ−1 mod (109+7)E_t = P Q^{-1} \bmod (10^9+7), where P/QP/Q is the expected number of players at checkpoint nn at moment tt, and QQ−1≡1(mod109+7)Q Q^{-1} \equiv 1 \pmod{10^9+7}. Bobo wants to know E1⊕E2⊕⋯⊕ETE_1 \oplus E_2 \oplus \dots \oplus E_T, where ⊕\oplus is bitwise exclusive or.

Input

The first line contains three integers nn, mm, and TT (1≤n≤701 \le n \le 70, 1≤m≤1041 \le m \le 10^4, 1≤T≤2×1061 \le T \le 2 \times 10^6). Each of the next nn lines contains a binary string Gi,1Gi,2…Gi,nG_{i,1} G_{i,2} \dots G_{i,n} of length nn. It is guaranteed that Gi,i=1G_{i,i} = 1. Each of the last mm lines contains two integers tit_i and viv_i (1≤t1<t2<⋯<tm≤T1 \le t_1 < t_2 < \dots < t_m \le T, 1≤vi≤n1 \le v_i \le n).

Output

Print one integer, the result.

Examples2

  1. Example 1

    Input
    2 2 2
    11
    11
    1 1
    2 2
    
    Expected output
    500000005
    
  2. Example 2

    Input
    3 1 6
    110
    011
    101
    1 1
    
    Expected output
    191901811