Under construction

Still being built. Things may change

Champernowne Substring

Time limit10sMemory limit2048 MB

Summary
Fill each ? in the pattern with a digit to minimize the index where it first appears in the Champernowne string, printed mod 998244353.
Level

Hard8 of 10

Topics
Dynamic programming, String, Math, Implementation
Solved
No attempts yet

Problem

The Champernowne string is an infinite string formed by concatenating the base-10 representations of the positive integers in order. It begins 1234567891011121314.... It can be proven that any finite string of digits appears as a substring in the Champernowne string at least once.

You are given a string made of digits and question marks. Replace each question mark with a single digit from 00 to 99. Find the smallest possible index at which the resulting string appears as a substring of the Champernowne string. Each question mark can be replaced with a different digit. The index can be large, so print it modulo 998,244,353998\\,244\\,353.

Input

The first line contains a single integer tt (1≤t≤10)(1 \leq t \leq 10), the number of test cases. Each of the next tt lines contains a string ss (1≤∣s∣≤25)(1 \leq |s| \leq 25) made of the digits 00 to 99 and question marks.

Output

For each test case, print one line with the smallest index modulo 998,244,353998\\,244\\,353.

Examples1

  1. Example 1

    Input
    9
    0
    ???1
    121
    1?1?1
    ??5?54?50?5?505?65?5
    000000000000
    ?2222222
    ?3????????9??8???????1??0
    9?9??0????????????2
    
    Expected output
    11
    7
    14
    10
    314159
    796889014
    7777
    8058869
    38886