Under construction

Still being built. Things may change

Poker Hand

Time limit1sMemory limit1024 MB

Summary
Given five cards per hand, the task is to find the largest number of cards that share the same rank.
Level

Easy1 of 10

Topics
Hash map, Implementation
Solved
No attempts yet

Problem

You are given a five-card hand drawn from a standard 52-card deck. Each card has a rank (one of A, 2, 3, ..., 9, T, J, Q, K) and a suit (one of C, D, H, S). The strength of your hand is the maximum value kk such that kk cards in your hand share the same rank.

Find the strength of your hand.

Input

The first line contains a single integer nn, the number of datasets. Each dataset is one line with five two-character strings separated by spaces. The first character of each string is the rank, one of A23456789TJQK. The second character is the suit, one of CDHS. All five strings are distinct.

Output

For each dataset, print the strength of the hand on a single line.

Examples1

  1. Example 1

    Input
    2
    AC AD AH AS KD
    2C 4D 4H 2D 2H
    
    Expected output
    4
    3