Codeforces Round 347 (Div. 2)
C
International Olympiad
Codeforces
未评级
原题
← BD →
翻译中…

International Abbreviation Olympiad takes place annually starting from 1989. Each year the competition receives an abbreviation of form IAO'y, where $*y*$ stands for some number of consequent last digits of the current year. Organizers always pick an abbreviation with non-empty string $*y*$ that has never been used before. Among all such valid abbreviations they choose the shortest one and announce it to be the abbreviation of this year's competition.

翻译中…

For example, the first three Olympiads (years 1989, 1990 and 1991, respectively) received the abbreviations IAO'9, IAO'0 and IAO'1, while the competition in 2015 received an abbreviation IAO'15, as IAO'5 has been already used in 1995.

翻译中…

You are given a list of abbreviations. For each of them determine the year it stands for.

翻译中…

Input

翻译中…

The first line of the input contains a single integer $*n*$ ($1 ≤ *n* ≤ 1000$) — the number of abbreviations to process.

翻译中…

Then $*n*$ lines follow, each containing a single abbreviation. It's guaranteed that each abbreviation contains at most nine digits.

翻译中…

Output

翻译中…

For each abbreviation given in the input, find the year of the corresponding Olympiad.

翻译中…

样例

Input #1
5
IAO'15
IAO'2015
IAO'1
IAO'9
IAO'0
Output #1
2015
12015
1991
1989
1990
InputCopy OutputCopy
Input #2
4
IAO'9
IAO'99
IAO'999
IAO'9999
Output #2
1989
1999
2999
9999
InputCopy OutputCopy
题目信息
题号
664C
时间限制
1 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。