{"problem":{"name":"A. Singhal and Swap","description":{"content":"_If you want to practice topicwise questions in the ladder way like a2oj , do register on my site *http://codedigger.tech* after the contest. Here you will get Handpicked Topicwise Questions from code","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10276A"},"statements":[{"statement_type":"Markdown","content":"_If you want to practice topicwise questions in the ladder way like a2oj , do register on my site *http://codedigger.tech* after the contest. Here you will get Handpicked Topicwise Questions from codeforces, codechef, uva and spoj for your better practice. Best of Luck._\n\nSinghal has two strings $S$ and $T$ consisting of lowercase English Letters. \n\nHe wants to obtain string $S$ lexicographically smallest possible. He can do the following operation any number of times: choose an index $p o s_1$ in the string $S$, choose an index $p o s_2$ in the string $T$, and swap $s_{p o s_1}$ with $t_{p o s_2}$.\n\nString $p$ is lexicographically smaller than string $q$,\n\nFor example, _abc_ is lexicographically smaller than _abcd_ , _abd_ is lexicographically smaller than _abec_ , _afa_ is not lexicographically smaller than _ab_ and _a_ is not lexicographically smaller than _a_.\n\n*Note: You have not to minimize number of operations and any index of both string can be chosen more than once.* \n\nThe first line contains a single integer $t (1 <= t <= 100)$ — the number of test cases in the input. Then $t$ test cases follow.\n\nEach query contains two lines. The first line contains a string $S (1 <= | S | <= 100)$ , and the second line contains a string $T (1 <= | T | <= 100)$. $| S |$ and $| T |$ is the length of the string $S$ and $T$ respectively.\n\n*Note: Both strings will have only lowercase English Letters.*\n\nFor each test from the input print lexicographical smallest possible string $S$. Print the answers to the tests in the order in which the tests are given in the input.\n\nIn the first query — swap($s_2, t_1$) to get smallest lexicographical possible.\n\nIn the second query — swap($s_2, t_1$) to get $S$ = _aac_ and $T$ = _bbc_, then swap($s_3, t_1$)to get $S$ = _aab_.\n\n## Input\n\nThe first line contains a single integer $t (1 <= t <= 100)$ — the number of test cases in the input. Then $t$ test cases follow.Each query contains two lines. The first line contains a string $S (1 <= | S | <= 100)$ , and the second line contains a string $T (1 <= | T | <= 100)$. $| S |$ and $| T |$ is the length of the string $S$ and $T$ respectively.*Note: Both strings will have only lowercase English Letters.*\n\n## Output\n\nFor each test from the input print lexicographical smallest possible string $S$. Print the answers to the tests in the order in which the tests are given in the input.\n\n[samples]\n\n## Note\n\nIn the first query — swap($s_2, t_1$) to get smallest lexicographical possible.In the second query — swap($s_2, t_1$) to get $S$ = _aac_ and $T$ = _bbc_, then swap($s_3, t_1$)to get $S$ = _aab_.","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 $ r_k, b_k \\in \\mathbb{Z} $ denote the number of red and blue balls, respectively.\n\n**Constraints**  \n1. $ 1 \\le T \\le 10 $  \n2. For each $ k \\in \\{1, \\dots, T\\} $: $ 1 \\le r_k, b_k \\le 100 $\n\n**Objective**  \nFor each test case $ k $, compute the probability $ P_k $ of selecting two red balls without replacement:  \n$$\nP_k = \\frac{\\binom{r_k}{2}}{\\binom{r_k + b_k}{2}} = \\frac{r_k(r_k - 1)}{(r_k + b_k)(r_k + b_k - 1)}\n$$  \nExpress $ P_k $ as an irreducible fraction $ \\frac{A}{B} $, where $ A, B \\in \\mathbb{Z} $, $ \\gcd(A, B) = 1 $, and $ B > 0 $. If $ P_k = 0 $, output $ 0/1 $; if $ P_k = 1 $, output $ 1/1 $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10276A","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}