logo AlgoBeat OnlineJudge
登录 注册

#209216. [SNCPC2019] Digit Mode

内存限制:256 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Let be the of the digits in decimal representation of positive integer . The mode is the largest value that occurs most frequently in the sequence. For example, , , , , , .

Given a positive integer , DreamGrid would like to know the value of .

输入格式

There are multiple test cases. The first line of the input contains an integer , indicating the number of test cases. For each test case:

The first line contains a positive integer () without leading zeros.

It's guaranteed that the sum of of all test cases will not exceed , where indicates the number of digits of in decimal representation.

输出格式

For each test case output one line containing one integer, indicating the value of .

样例

样例输入 1

5
9
99
999
99999
999999

样例输出 1

45
615
6570
597600
5689830