I need to write a program, that lists keystrings for each command for a given set of commands.


Input

The first line contains the number n of commands for the console application.

Each of the following n lines contains one command of the client.

Each command is a nonempty string consisting of lowercase Latin letters and its length is at most 100.

No command is a proper substring of another command.

Output

Output n lines.

The i-th line should contain any of the shortest key substrings of the i-th command (the commands are numbered in the order they are given in the input).

Sample

input output

3

abcm ab

acm ac

bcd d

abd abd


I first need to know how to split a string like "abcd" into a b c d separately. I can't use strtok() because it take a delimiter like space, comma or hyphen etc. I can't use delimiters within the same word. Please help me out.

Thanks,
Kahaly

>>I first need to know how to split a string like "abcd" into a b c d separately

Why don't you use an index? What i mean is,

char letterArray[100];
for (i = 0; i < strlen(str); i++) {
    letterArray[i] = str[i];
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.