Under construction

Still being built. Things may change

Card Draw

Interview

Time limit1sMemory limit1024 MB

Summary
For each day's four cards, check whether they form a consecutive triple, a triple of identical cards, or two identical pairs.
Level

Easy3 of 10

Topics
Implementation, Brute force
Solved
No attempts yet

Problem

Sangpil studies algorithms every day by solving problems steadily. After solving problems for a long time, he felt tired and needed a day off. So he decided to pick his rest days by drawing cards.

The deck has 27 cards. Each card shows one nonzero digit and one lowercase letter, m, p, or s (1m, 2m, ⋯\cdots, 9m, 1p, 2p, ⋯\cdots, 9p, 1s, 2s, ⋯\cdots, 9s). He draws one card, memorizes it, and returns it to the deck. He repeats this 4 times. If the 4 drawn cards satisfy at least one of the rules below, he rests that day.

  • Three cards have the same letter, and their digits are consecutive. The three consecutive digits must be different from each other.
  • Three cards have the same letter and the same digit.
  • When the cards are split into two pairs, the cards in each pair have the same digit and letter.

Sangpil drew the cards for days 1 to T in advance, but he could not easily tell which days were rest days. He thought he could solve it with the algorithms he had studied so far. Today he decided to rest, so he asked you to figure it out.

Input

The first line contains an integer T (1≤T≤1001 \le T \le 100).

From line 2 to line T+1T+1, line i+1i+1 contains the 4 cards drawn for day ii, separated by spaces (1≤i≤T1 \le i \le T).

Output

Print T lines. On line ii, print :) if day ii is a rest day, and :( otherwise.

Examples1

  1. Example 1

    Input
    8
    2s 7p 4s 3s
    8m 9m 1m 2m
    5p 5p 6s 5p
    2m 2p 2s 2s
    7p 1m 1m 7p
    9s 9s 9s 9s
    6p 8m 6p 8s
    3p 4p 4p 5p
    
    Expected output
    :)
    :(
    :)
    :(
    :)
    :)
    :(
    :)