B. Paper Game

Codeforces
IDCF10102B
Time1000ms
Memory64MB
Difficulty
English · Original
Formal · Original
Hasan and Hussain are playing a game with W × H paper, the game consist of turns; Hasan starts first. On each turn, the player chooses one of the pieces of paper and cuts it into two papers such that the cut must be a straight line parallel to one of the paper sides and must cut the paper to two pieces of paper with integer dimensions. The loser is the one who can't make a move (i.e when all pieces of paper become 1 × 1). Assuming that Hasan and Hussain are playing optimally, who will win the game? The first line of input is an integer T(1 ≤ T ≤ 101) which represents the number of test cases. Each of the next T lines consists of two space-separated integers W,H (1 ≤ W,H ≤ 100,000) the width and the height of the paper. For each test case, output a single line representing its answer; if Hasan is the winner output "Hasan" (without quotes) otherwise "Hussain" (without quotes). ## Input The first line of input is an integer T(1 ≤ T ≤ 101) which represents the number of test cases. Each of the next T lines consists of two space-separated integers W,H (1 ≤ W,H ≤ 100,000) the width and the height of the paper. ## Output For each test case, output a single line representing its answer; if Hasan is the winner output "Hasan" (without quotes) otherwise "Hussain" (without quotes). [samples]
**Definitions** Let $ t \in \mathbb{Z} $ be the number of test cases. For each test case $ k \in \{1, \dots, t\} $, let $ s_k^{(1)}, s_k^{(2)} $ be two strings over the English alphabet (uppercase and lowercase). **Constraints** 1. $ 1 \le t \le 1000 $ 2. For each $ k $, $ 1 \le |s_k^{(1)}|, |s_k^{(2)}| \le 100 $ 3. Each character in $ s_k^{(1)}, s_k^{(2)} $ is an English letter (a–z, A–Z) **Objective** For each test case $ k $, determine whether $ s_k^{(1)} $ and $ s_k^{(2)} $ are *Arabic-similar*, defined as: - Ignore case: treat uppercase and lowercase letters as identical. - Replace all occurrences of `'b'` and `'p'` (in any case) with a common canonical form (e.g., map both to `'b'` or `'p'`). - Replace all occurrences of `'i'` and `'e'` (in any case) with a common canonical form. Formally, define a canonicalization function $ f: \Sigma^* \to \Sigma^* $ where: - $ f(c) = \text{lower}(c) $ for all $ c \in \Sigma $, - Then: - If $ f(c) = 'p' $, set $ f(c) = 'b' $, - If $ f(c) = 'e' $, set $ f(c) = 'i' $. Then, $ s_k^{(1)} $ and $ s_k^{(2)} $ are Arabic-similar if and only if: $$ f(s_k^{(1)}) = f(s_k^{(2)}) $$ Output "Yes" if equal, "No" otherwise.
API Response (JSON)
{
  "problem": {
    "name": "B. Paper Game",
    "description": {
      "content": "Hasan and Hussain are playing a game with W × H paper, the game consist of turns; Hasan starts first. On each turn, the player chooses one of the pieces of paper and cuts it into two papers such that ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 65536
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10102B"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Hasan and Hussain are playing a game with W × H paper, the game consist of turns; Hasan starts first. On each turn, the player chooses one of the pieces of paper and cuts it into two papers such that ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ t \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case $ k \\in \\{1, \\dots, t\\} $, let $ s_k^{(1)}, s_k^{(2)} $ be two strings over the English alphabet (uppercase...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments