QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#13647. 围绕着我们的圆环

统计

"I do not believe that sad things and difficult things are in vain. If that is fate, then there must be a meaning to it. I will accept them all and become stronger. So—please stop for me." —— Mawaru Penguindrum

If fate is written from the very beginning, what is the meaning of survival?

I want to live for you, and I want you to live for me.

As long as there is one person who needs you, living has meaning.

Lihua and Rosemary shared the fruit of fate together, sharing both love and punishment.

Fate is a predetermined $p \times s$ binary matrix $C$, which is fixed.

Love is a $p \times q$ binary matrix $A$, and punishment is a $q \times s$ binary matrix $B$.

The fruit of fate consists of love and punishment, satisfying $C[i][j]=(\sum\limits_{k=1}^qA[i][k] \times B[k][j]) \pmod 2$.

Even though fate is predetermined, there are many possibilities for love and punishment, and Lihua and Rosemary cannot help but want to calculate them.

They will not simply board the train of fate and arrive at the destination fate has set; they will also transfer to their own fate.

Therefore, there are $m$ fate transfers. At each fate transfer point, Lihua and Rosemary recite a spell in the name of love and transfer their fate.

A fate transfer modifies a certain row of matrix $C$. After each modification, Lihua and Rosemary wish to recalculate the number of possibilities for love and punishment.

Since the number of possibilities can be very large, they only wish to know the answer modulo $1\,000\,000\,007$.

Input

The first line contains five integers: $p, q, s, m, k$.

Next, read the matrix $C$, which consists of $p$ lines, each containing $s$ numbers.

Then, $m$ lines follow, each representing a modification. Each line starts with a number $j$, indicating that the row being modified is the $j \operatorname{xor} (k \cdot \text{ans})$-th row, where $\text{ans}$ is the answer before the modification. Then, $s$ numbers follow, representing the new values for that row.

Output

Output one integer per line representing the answer before any modifications and after each modification.

Examples

Input 1

2 2 2 1 0
0 1
1 0
1 1 0

Output 1

6
18

Constraints

For all data, $1\le p,q,s,m\le 1000$, $k\in\{0,1\}$.

Let $n$ be the maximum of $p, q, s$.

Property $A$ means the data is random; the initial matrix, which row is modified, and the new values are all generated randomly. If there are no extra restrictions, $p, q, s$ are randomly generated in $(n-5, n]$ (e.g., subtask 10). If $p=q=s=o$ is restricted, then $o$ is randomly generated in $(n-100, n]$ (e.g., subtask 6).

Property $B$ means $p=q=s$.

Property $C$ means the initially read matrix $C$ is an identity matrix.

Subtask Constraints Properties Score
1 $n\le 3,m=0$ 4
2 $n\le 4,m=0$ 6
3 $n\le 5,m=0$ 5
4 $n\le 300,m=0$ 15
5 $n\le 300,m\le 1000$ 11
6 $n\le 700,m=0$ AB 7
7 $n\le 1000,m=0,p=s$ C 6
8 $n\le 1000,m=0$ 16
9 $p,q,m\le 1000,s\le 100,k=0$ 12
10 $n,m\le 1000$ A 10
11 $n,m\le 1000$ 8

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.