This page is still under construction.

Parts of this page are still being built. What you see may change.

New Friends

Time limit1sMemory limit128 MB

Summary
Given up to 10 town names, partition them into the fewest groups where every pair of names in a group differ by at most one Levenshtein edit (case ignored).
Level

Medium6 of 10

Topics
String, Graph, Brute force, Backtracking
Solved
No attempts yet

Problem

During a nice day at the beach you meet new people who might become your friends. To stay in touch you write down each person's name together with the town they came from. Afterwards you wonder how many different towns these people actually came from.

This is complicated by the typos you make while writing the town names down. If you record one person as being from "Pasadena" and another from "Passadena", it looks like two towns even though it might be one. So you need a program to account for these mistakes.

Each town name is a string of uppercase and lowercase letters and the character -. Case is ignored, so "SAN-DIEGO" and "san-diEgo" denote the same town. Two names may denote the same town when, after ignoring case, they are equal or differ by exactly one character — a single insertion, deletion, or replacement (a Levenshtein edit distance of at most 11). For example "SanDIego" and "san-diego" could be the same town, but "san-diego" and "san-deigo" could not.

A group of people can all come from one town only if every pair of their names differs by at most one character. It is not enough that some single name exists within one character of all of them. For example, given the three names "Tijuana", "tejuana", and "TI-Juana", every name is within one character of "Tijuana", yet "tejuana" and "TI-Juana" differ by two characters, so those two people cannot share a town — you must assume at least two towns.

Compute the minimum number of towns these people could be coming from.

Of course, you also meet a lot of people who you would never want to be friends with. Ever.

Input

The first line contains an integer K≥1K \ge 1, the number of data sets. Each data set has the following form:

  • The first line contains an integer nn with 1≤n≤101 \le n \le 10, the number of new friends you met.
  • Each of the next nn lines contains one string of length between 11 and 100100, the town one friend came from.

Output

For each data set, first print Data Set x: on its own line, where x is the data set's number (starting from 11). Then print the minimum number of towns these people could be from.

Examples1

  1. Example 1

    Input
    2
    3
    Tijuana
    tejuana
    TI-Juana
    5
    Cancun
    Can-Cun
    can-can
    canccun
    CANKUN
    
    Expected output
    Data Set 1:
    2
    Data Set 2:
    3