Under construction

Still being built. Things may change

Fix-Free Check

Interview

Time limit1sMemory limit128 MB

Summary
For each triple of words, decide whether no word is a prefix or suffix of another, printing Yes or No.
Level

Easy3 of 10

Topics
String, Brute force, Implementation, Sorting
Solved
No attempts yet

Problem

A collection of words is prefix-free if no word is a prefix of any other word. A collection of words is suffix-free if no word is a suffix of any other word. A collection of words is fix-free if it is both prefix-free and suffix-free.

In this problem, a word is a sequence of lower-case letters whose length is between 11 and 2525. A word XX is a prefix of a word YY if, for some nn, XX consists of the first nn characters of YY in order. For example, the prefixes of the word cat are c, ca, and cat. Similarly, a word XX is a suffix of YY if XX consists of the last nn characters of YY in order.

Input

The first line contains the number of collections NN. The following 3N3N lines describe the NN collections in order, with three words per collection and one word per line. That is, lines 22, 33, and 44 form the first collection, lines 55, 66, and 77 form the second collection, and so on.

Output

For each collection, print one line containing Yes if that collection is fix-free, or No otherwise. Print NN lines in the order the collections are given.

Examples3

  1. Example 1

    Input
    2
    abba
    aab
    bab
    a
    ab
    aa
    
    Expected output
    Yes
    No
    
  2. Example 2

    Input
    1
    cat
    at
    dog
    
    Expected output
    No
    
  3. Example 3

    Input
    1
    abc
    bca
    cab
    
    Expected output
    Yes