Phone List
InterviewTime limit1sMemory limit256 MB
Given a list of distinct phone numbers, decide whether any number is a prefix of another.
Problem
You are given a list of phone numbers. Write a program that determines whether the list is consistent.
A list is consistent if no phone number is a prefix of another phone number.
For example, consider the following list of phone numbers:
- Emergency:
911 - Sanggeun:
97 625 999 - Seonyeong:
91 12 54 26
In this case it is impossible to call Seonyeong. The moment you dial the first three digits 911 of Seonyeong's number, you are connected to the emergency line. Therefore this list is not consistent.
Input
The first line contains the number of test cases ().
The first line of each test case contains the number of phone numbers ().
The next lines each contain one phone number from the list. Each phone number is at most 10 digits long, and no phone number appears twice in the same list.
Output
For each test case, print YES if the list is consistent, and NO otherwise, each on its own line.