Codeforces Round 434 (Div. 1, based on Technocup 2018 Elimination Round 1)
B
Polycarp's phone book
Codeforces
未评级
原题
← AC →
翻译中…

There are $*n*$ phone numbers in Polycarp's contacts on his phone. Each number is a 9-digit integer, starting with a digit different from $0$. All the numbers are distinct.

翻译中…

There is the latest version of Berdroid OS installed on Polycarp's phone. If some number is entered, is shows up all the numbers in the contacts for which there is a substring equal to the entered sequence of digits. For example, is there are three phone numbers in Polycarp's contacts: $123456789$, $100000000$ and $100123456$, then:

翻译中…
  • if he enters $00$ two numbers will show up: $100000000$ and $100123456$,
  • if he enters $123$ two numbers will show up $123456789$ and $100123456$,
  • if he enters $01$ there will be only one number $100123456$.
翻译中…

For each of the phone numbers in Polycarp's contacts, find the minimum in length sequence of digits such that if Polycarp enters this sequence, Berdroid shows this only phone number.

翻译中…

Input

翻译中…

The first line contains single integer $*n*$ ($1 ≤ *n* ≤ 70000$) — the total number of phone contacts in Polycarp's contacts.

翻译中…

The phone numbers follow, one in each line. Each number is a positive 9-digit integer starting with a digit from $1$ to $9$. All the numbers are distinct.

翻译中…

Output

翻译中…

Print exactly $*n*$ lines: the $*i*$-th of them should contain the shortest non-empty sequence of digits, such that if Polycarp enters it, the Berdroid OS shows up only the $*i*$-th number from the contacts. If there are several such sequences, print any of them.

翻译中…

样例

Input #1
3
123456789
100000000
100123456
Output #1
9
000
01
InputCopy OutputCopy
Input #2
4
123456789
193456789
134567819
934567891
Output #2
2
193
81
91
InputCopy OutputCopy
题目信息
题号
860B
时间限制
4 s
内存限制
256 MB

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