Problem: In a game of chess, Check is a game position in which a player's King is under attack by any of the opponent's pieces.

Bob is playing with Chess pieces. He randomly arranges three pieces on 8x8 chessboard: a black's King , a white's King and any one of the white's Queen, Knight, Bishop or Rook. Positions of these pieces are known to us (positions are described following the standard chess notations) . Bob is interested in finding if black's King is under 'check' or not?

Input:
First line contains integer T - number of test cases.
Each test case contains two lines.
First line contains two strings describing the positions of black's King and white's King
Second line contains either q, k, b, or r and its position. (q = queen, k = knight, b = bishop and r = rook)

Output:
For each test case print "check"(without quotes) if black's King is under 'check' else print "-1"(without quotes)

Constraints: 
1 ≤ T ≤ 10
Each position is a two character alpha-numeric string.
All positions in a test case will be different.
First character of each position will be a lower-case alphabet in the range [a,h] and second character will be an integer in the range [1,8]

Sample tests explanation:

SAMPLE INPUT
4
e8 e1
q a4
e7 d3
b f6
h6 g4 
k h4
d8 e1
r d3

SAMPLE OUTPUT
check
check
-1
check

Solution (in PYTHON):

Solution:
#!/usr/bin/python

def getCoords(p):
    if p[0] == 'a':
        y = 1
    elif p[0] == 'b':
        y = 2
    elif p[0] == 'c':
        y = 3
    elif p[0] == 'd':
        y=4
    elif p[0] == 'e':
        y=5
    elif p[0] == 'f':
        y=6
    elif p[0] == 'g':
        y=7
    elif p[0] == 'h':
        y=8

    x=p[1]
    return [int(x),int(y)]

def getSlope(p1,p2):
    if p1[0] == p2[0]:
        return int(0)
    elif p1[1] == p2[1]:
        return int(0)
    else:
        return float(p2[1] - p1[1])/float(p2[0] - p1[0])

testCases = int(raw_input())

for case in range(0,testCases):
    kPositions = str(raw_input())
    otherPosition = str(raw_input())
    bKPoint = getCoords(kPositions[0:2])
    wKPoint = getCoords(kPositions[3:]) 
    oType = otherPosition[0]
    oPoint = getCoords(otherPosition[2:])
    m1 = getSlope(oPoint,bKPoint)
    m2 = getSlope(oPoint,wKPoint)
    okDist = abs((((oPoint[1]-bKPoint[1])**2)+((oPoint[0]-bKPoint[0])**2)) ** (0.5))
    wkDist = abs((((wKPoint[1]-bKPoint[1])**2)+((wKPoint[0]-bKPoint[0])**2)) ** (0.5))

    if oType == 'r':
        if (oPoint[0] == bKPoint[0] or oPoint[1] == bKPoint[1]) and okDist <= wkDist:
            print 'check'
            continue
    elif oType == 'b':
        if abs(m1) == 1:
            if m1 != m2:
                print 'check'
                continue
            elif okDist <= wkDist:
                print 'check'
                continue
    elif oType == 'k':
        if ( abs(m1) == 2.0 or abs(m1) == 0.5 ) and ((abs(bKPoint[0] - oPoint[0]) + abs(bKPoint[1] - oPoint[1])) == 3):
            print 'check'
            continue
    elif oType == 'q':
        if ( abs(m1) == 1 or m1 == 0 ):
            if m1 != m2:
                print 'check'
                continue
            elif okDist <= wkDist:
                print 'check'
                continue
    
    print '-1'