{"raw_statement":[{"iden":"statement","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 loves Equality. He has a string $S$ consisting of lowercase English Letters.\n\nHe wants to equalize the frequency of all distinct characters in his string $S$. He can do the following operation any number of times: pick any single character in the string and replace with another lowercase English alphabet.\n\nHe wants to perform minimum number of operations to equalize the frequency of distinct characters.\n\nFrequency of a character is number of times it appear in the string.\n\nThe first line contains a single integer $t (1 <= t <= 10^5)$ — the number of test cases in the input. Then $t$ test cases follow.\n\nEach query contains a single string consisting of lowercase English letters $S (1 <= | S | <= 10^5)$. $| S |$ is the length of the string. \n\nIt is guaranteed that the total sum of $| S |$ is at most $10^5$.\n\nPrint $t$ answers to the test cases. Each answer must be consisting of single integer — the minimum number of operations required to equalize the frequency of distinct characters of string.\n\nIn the first query — We can replace letter $b arrow.r a$ to form _aaa_. Now frequency of all distinct character is same i.e. $3$ or another possibility is replace one $a arrow.r c$ to form _abc_. In this case frequency is $1$.\n\nIn the second query — Frequency of all distinct character is Same i.e. $2$. No need to apply operation.\n\n"},{"iden":"input","content":"The first line contains a single integer $t (1 <= t <= 10^5)$ — the number of test cases in the input. Then $t$ test cases follow.Each query contains a single string consisting of lowercase English letters $S (1 <= | S | <= 10^5)$. $| S |$ is the length of the string. It is guaranteed that the total sum of $| S |$ is at most $10^5$."},{"iden":"output","content":"Print $t$ answers to the test cases. Each answer must be consisting of single integer — the minimum number of operations required to equalize the frequency of distinct characters of string."},{"iden":"note","content":"In the first query — We can replace letter $b arrow.r a$ to form _aaa_. Now frequency of all distinct character is same i.e. $3$ or another possibility is replace one $a arrow.r c$ to form _abc_. In this case frequency is $1$.In the second query — Frequency of all distinct character is Same i.e. $2$. No need to apply operation."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case:  \n- Let $ n, m, Q \\in \\mathbb{Z} $ denote the grid dimensions and number of queries.  \n- Let $ G \\in \\{ \\texttt{'}.\\texttt{'} , \\texttt{'}#\\texttt{'} \\}^{n \\times m} $ be the grid, where $ G[i][j] = \\texttt{'}#\\texttt{'} $ means dry, $ \\texttt{'}.\\texttt{'} $ means wet.  \n- Let $ \\mathcal{Q} = \\{ (t_i, x_i, y_i) \\mid i \\in \\{1, \\dots, Q\\} \\} $ be the sequence of queries, where $ t_i \\in \\{1, 2\\} $.\n\n**Constraints**  \n1. $ 1 \\le T \\le 1000 $  \n2. $ 1 \\le n, m, Q \\le 10^3 $  \n3. $ \\sum \\max(n, m, Q) \\le 2 \\times 10^4 $ over all test cases  \n4. For each query:  \n   - If $ t_i = 1 $: toggle state of cell $ (x_i, y_i) $ (dry ↔ wet)  \n   - If $ t_i = 2 $: compute maximum area of axis-aligned $ a \\times b $ rectangular frame (width 1) with dry boundary only, where $ a \\ge 1, b \\ge 1 $\n\n**Objective**  \nFor each query with $ t_i = 2 $:  \nCompute  \n$$\n\\max \\left\\{ a \\cdot b \\ \\middle|\\ \n\\begin{array}{c}\n1 \\le a \\le n,\\ 1 \\le b \\le m, \\\\\n\\text{the frame of } a \\times b \\text{ rectangle has all boundary cells dry}\n\\end{array}\n\\right\\}\n$$  \nIf no such frame exists, output $ 0 $.","simple_statement":"Alex has an n×m grid. Each cell is either dry ('#') or wet ('.').  \nHe wants to build a rectangular wall frame (1-cell thick) of size a×b (a rows, b columns).  \nThe wall can only be built on dry cells.  \n\nHe gets Q queries:  \n- Type 1: Flip a cell (dry ↔ wet)  \n- Type 2: Find the largest possible area of a valid wall frame  \n\nIf no wall can be built, output 0.","has_page_source":false}