题目描述
Problem Background
The hell of the Double Ninth Festival...
Shikieiki Yamaxanadu (referred to as Shikieiki-sama) is the highest judge in hell. She usually determines the guilt of the deceased, deciding whether they go to hell, heaven, or elsewhere.
Shikieiki-sama can easily judge the guilt of the deceased, but there are too many of them. Shikieiki-sama needs your help to judge their guilt so she can free up time to preach to others.
Problem Description
The guilt value \( E \) of a person is determined by the actions they committed during their life and their manner of death. Each bad deed they committed has a guilt value. These bad deeds may be grouped together, and the guilt value of a group is the maximum guilt value of the deeds within that group. The actions they committed during their life influence each other, and we categorize these actions into four types, with the final guilt value \( E \) being the sum of the guilt values of all groups.
- Committing a bad deed – Has a guilt value, forms a single group.
- Doing a good deed – Clears the guilt value of a bad deed.
- Repenting – Reduces the guilt value of the deed with the maximum guilt value in the specified group. If the maximum guilt value is less than the reduction amount, the guilt value of that deed is cleared. For deeds with equal guilt values, the one with the smaller number is considered worse.
- Recognizing oneself – Merges two bad deed groups.
The manner of death can be categorized as natural death, accidental death, or suicide.
- Natural death has no effect.
- Accidental death can exempt the group with the maximum guilt value.
- Suicide doubles the guilt value of the group with the maximum guilt value.
Input Format
The first line contains three inputs \( T, W, K \), representing the number of people waiting for judgment, the manner of death (corresponding to the description numbers), and the meaning of \( K \) as described in the output format.
The next \( T \) sets of data, each set starting with two inputs \( n, m \), representing the number of bad deeds and the number of other actions they committed.
The second line contains \( n \) inputs, representing the guilt values of each bad deed.
From the third line to the \( m+2 \)-th line, each line has three possible inputs (refer to the problem description for understanding):
2 A: Indicates doing a good deed, clearing the guilt value of bad deed \( A \).3 A B: Indicates repenting, specifying the group where \( A \) is located, reducing the maximum guilt value by \( B \). If the maximum guilt value is less than \( B \), the guilt value of that deed is cleared.4 A B: Indicates recognizing oneself, merging the group where \( B \) is located with the group where \( A \) is located.
Output Format
For each person, output a string and an integer on one line.
If their guilt value is \( 0 \), output Gensokyo. If their guilt value is greater than \( K \), output Hell. Otherwise, output Heaven. Then output their guilt value.
Sample Input and Output
Sample Input #1
1 1 10
5 2
1 2 3 4 5
2 3
4 2 4
Sample Output #1
Heaven 10
Sample Input #2
2 2 8
5 4
4 8 7 5 6
4 2 4
2 2
4 2 3
3 3 2
3 2
5 1 2
2 2
3 3 2
Sample Output #2
Hell 9
Gensokyo 0
Sample Input #3
2 1 15
5 4
1 2 3 4 5
4 2 3
3 2 100
4 1 4
4 4 1
5 4
1 2 3 4 5
3 2 15
4 2 3
4 1 4
4 3 4
Sample Output #3
Heaven 11
Heaven 9
Notes/Hints
Sample 1 Explanation
Initially, there are five bad deeds with guilt values \( 1, 2, 3, 4, 5 \). After doing a good deed, the guilt values become \( 1, 2, 0, 4, 5 \). After recognizing oneself, there are four groups left with guilt values \( 1, 4, 0, 5 \). Since it is a natural death, the final guilt value \( E = 1 + 4 + 5 = 10 \leq K \&\& E \neq 0 \), so the output is Heaven.
Sample 2 Explanation
For the first set of inputs in Sample 2, as shown in the diagram below, the black ellipse represents a group, the red number is the guilt value, and the bottom number is the point's ID. Since it is an accidental death, the group with the maximum value (ID 5) can be exempted, so the guilt value is \( E = 4 + 5 \).

Notes
All data are within the range of long integers. For all data, \( m \leq n \), \( 1 \leq K \), and negative numbers are not guaranteed in the input.
Due to the potential size of the input data, it is recommended to use fast input methods.
Conventions:
1. For the operation of merging two groups, at least one group contains only one bad deed.
2. These people will not do good deeds.
| Test Case Number | T | n | Time Limit | Conventions |
|---|---|---|---|---|
| 1 | \(\leq 10\) | \(\leq 100\) | 1s | 1, 2 |
| 2 | \(\leq 10\) | \(\leq 300\) | 1s | 1 |
| 3 | \(\leq 10\) | \(\leq 500\) | 1s | |
| 4 | \(\leq 20\) | \(\leq 1000\) | 1s | 1, 2 |
| 5 | \(\leq 20\) | \(\leq 3000\) | 1s | 1 |
| 6 | \(\leq 20\) | \(\leq 7000\) | 1s | |
| 7 | \(\leq 30\) | \(\leq 10000\) | 1s | 1, 2 |
| 8 | \(\leq 30\) | \(\leq 30000\) | 1s | 1 |
| 9 | \(\leq 30\) | \(\leq 50000\) | 1s | |
| 10 | \(\leq 30\) | \(\leq 70000\) | 1s | 1, 2 |
| 11 | \(\leq 10\) | \(\leq 100000\) | 1s | 1 |
| 12 | \(\leq 10\) | \(\leq 150000\) | 1s | |
| 13 | \(\leq 10\) | \(\leq 200000\) | 1s | 1, 2 |
| 14 | \(\leq 10\) | \(\leq 500000\) | 1s | 1 |
| 15 | \(\leq 10\) | \(\leq 1000000\) | 2s | |
| 16 | \(\leq 10\) | \(\leq 1000000\) | 2s | 1, 2 |
| 17 | \(\leq 10\) | \(\leq 1000000\) | 2s | 1 |
| 18 | \(\leq 10\) | \(\leq 2000000\) | 2s | |
| 19 | \(\leq 10\) | \(\leq 2000000\) | 2s | |
| 20 | \(\leq 10\) | \(\leq 2000000\) | 2s | |
| 21 | 1 | \(\leq 2000000\) | 2s | Path Compression |
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分