#P13562. 「WWOI R1」WsW 的田地

「WWOI R1」WsW 的田地

Background

WsW can be happy and angry.

Problem Description

WsW and bln each have a piece of farmland. Both farmlands consist of n×mn\times m cells, where the top-left cell has coordinates (1,1)(1,1) and the bottom-right cell has coordinates (n,m)(n,m).

At the beginning, in WsW's farmland, the cell at (x,y)(x,y) has a seedling with growth value ax,ya_{x,y}; in bln's farmland, the cell at (x,y)(x,y) has a seedling with growth value bx,yb_{x,y}.

At the beginning of each following day, a little fairy uses a potion on the cell (x0,y0)(x_0,y_0) in either WsW's or bln's farmland. There are three types of potions:

  • Potion 11, with 33 parameters, increases the growth value by kk for every cell (x,y)(x,y) in that farmland that satisfies x=x0x=x_0 or y=y0y=y_0.
  • Potion 22, with 55 parameters, increases the growth value by kk for every cell (x,y)(x,y) in that farmland that satisfies x0xx0+ux_0\le x\le x_0+u and y0yy0+vy_0\le y\le y_0+v.
  • Potion 33, with 55 parameters, increases the growth value by kk for every cell (x,y)(x,y) in that farmland that satisfies x0xx0+ux_0\le x\le x_0+u and y0+xx0yy0+xx0+vy_0+x-x_0\le y\le y_0+x-x_0+v.

The potion does not affect areas outside the farmland.
The potion takes effect instantly, and its effect does not disappear after the end of the day.

After the fairy uses a potion, WsW checks both their own farmland and bln's farmland. If, for every cell with the same coordinates in the two farmlands, the growth values are all equal, then WsW will be very happy; otherwise, WsW will be very angry.

Input Format

The first line contains two integers n,mn,m, representing the size of the farmlands.

The next nn lines each contain mm numbers, describing the initial growth values of the seedlings in WsW's farmland.
The next nn lines each contain mm numbers, describing the initial growth values of the seedlings in bln's farmland.

The next line contains a positive integer qq, meaning there are qq days in total.

The next qq lines each describe one potion use. First read two integers t,ft,f. Here tt is the potion type. If f=0f=0, the potion is used on WsW's farmland; if f=1f=1, it is used on bln's farmland. Then:

  • If t=1t=1, it means potion 11 is used. Then input 33 integers x0,y0,kx_0,y_0,k.
  • If t=2t=2, it means potion 22 is used. Then input 55 integers x0,y0,k,u,vx_0,y_0,k,u,v.
  • If t=3t=3, it means potion 33 is used. Then input 55 integers x0,y0,k,u,vx_0,y_0,k,u,v.

Output Format

Output qq lines in total, describing WsW's mood after the potion is used each day.
If WsW is very happy, output Happy; if WsW is very angry, output Angry.

2 3
1 1 4
5 1 4
0 0 3
5 0 4
5
1 1 1 2 1
1 0 1 1 4
1 1 1 3 4
2 1 2 1 4 0 1
2 0 2 2 4 0 1
Happy
Angry
Angry
Angry
Happy
3 3
1 9 1
9 8 1
3 0 5
3 11 1
9 10 3
3 0 5
1
3 1 1 1 -2 1 1
Happy

Hint

Sample 1 Explanation

The red numbers indicate the growth values in the cells that change on that day.

It can be seen that only on day 11 and day 55 do the corresponding cells in the two farmlands have the same growth values.

Constraints

This problem uses bundled testdata.

For all testdata, it is guaranteed that:

  • 1n,m8001\le n,m\le 8001q5×1051\le q\le 5\times 10^5.
  • For all ax,y,bx,ya_{x,y},b_{x,y}, we have ax,y,bx,y5×105|a_{x,y}|,|b_{x,y}|\le 5\times 10^5.
  • t{1,2,3}t\in \{1,2,3\}, f{0,1}f\in \{0,1\}.
  • 1x0n1\le x_0\le n, 1y0m1\le y_0\le m, k5×105|k| \le 5\times 10^5, 0un0\le u\le n, 0vm0\le v\le m.
Subtask ID n,mn,m\le qq\le $\lvert a_{i,j}\rvert,\lvert b_{i,j}\rvert,\lvert k\rvert\le$ Special Restriction Score
11 100100 Guaranteed that there is no case with t=3t=3. 1010
22 ^ None. 2020
33 800800 5×1055\times10^5 5×1055\times 10^5 Guaranteed that there is no case with t=3t=3. 3030
44 ^ None. 4040

Translated by ChatGPT 5