{"problem":{"name":"D. Polycarp's phone book","description":{"content":"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","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":4000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF858D"},"statements":[{"statement_type":"Markdown","content":"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.\n\nThere 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:\n\n*   if he enters 00 two numbers will show up: 100000000 and 100123456,\n*   if he enters 123 two numbers will show up 123456789 and 100123456,\n*   if he enters 01 there will be only one number 100123456.\n\nFor 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.\n\n## Input\n\nThe first line contains single integer _n_ (1 ≤ _n_ ≤ 70000) — the total number of phone contacts in Polycarp's contacts.\n\nThe 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.\n\n## Output\n\nPrint 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.\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"CF858D","tags":["data structures","implementation","sortings"],"sample_group":[["3\n123456789\n100000000\n100123456","9\n000\n01"],["4\n123456789\n193456789\n134567819\n934567891","2\n193\n81\n91"]],"created_at":"2026-03-03 11:00:39"}}