#DCEPC12E. End of Fun

End of Fun

Its holiday time after exams and Kappi and Pushap are enjoying to its fullest. But the sadist Sid, their 

teacher, can’t see them enjoy. Sad isn’t it? To ruin their fun, he gave them a programming problem to be 

solved within next 5 hours. He gives them 2 square matrices of equal dimension, Matrix A and a Matrix 

B and asks multiple queries on these matrices. The queries will be to change a particular element of one 

of the matrix and output the sum of elements of product of their matrix. Sid asks a lot of such queries. 

Kappi and Pushap don’t want the end of fun and so they ask you to solve this problem on behalf of 

them.

 

Input

First line consists of N, the dimension of matrix.

Each of the next N lines contains N space separated integers. This is matrix A.

Each of the next N lines contains N space separated integers. This is matrix B.

Next line contains Q, the number of queries asked by Sid.

Each of the next Q lines consists of queries of the form “A i j K” or “B i j K” (quotes for clarity), meaning 

change the element in ith row and jth column of matrix A or B to value K.

Output

Output exactly Q lines corresponding to Q queries, each containing the sum of the elements of the 

matrix A*B.

Example

Input:
2

1 2

3 4

4 3

2 1

3

A 1 1 2

B 0 1 3

A 0 0 10

Output: 40

40

103

</p>
Constraints:

1<=N<=100

1<=Q<=100000

0<=i,j<N

-10^6 <= A[i][j], B[i][j] <= 10^6