Snakes in Sabar again

0

0 votes
Problem

PROBLEM STATEMENT:

Snakes have been lurking again in Sabar lately. SAC, the Serpentine Action Committee has put up an investigation team to pinpoint the location of the Snake. You are the Student member of the SAC. Help the team find the snake.

Sabar has l blocks. Each block of the l blocks has m floors and each floor of the m floors has n rooms. You are given three arrays A, B, C of unique block names (block names are single alphabets like d, k, s), unique floor numbers and unique room numbers (The block names, floor numbers and room numbers may not be continuous).

A friend has tipped you off the coordinates (p, q, r) of the snake where p is the block name, is the floor number and r is the room number where the snake is. If the coordinates exist, print, "SNAKE FOUND" else, your friend has lied to you so print "DOST HI SAANP HAI".

 

INPUT FORMAT:

  • The first line contains the number of test cases T. For each test case, the below five lines follow:
  • The first line contains three space-separated integers lmn denoting the number of blocks, floors and room numbers.
  • The next line contains l space-separated alphabets, denoting the block names.
  • The next line contains space-separated numbers, denoting the floor numbers.
  • The next line contains space-separated numbers, denoting the room numbers.
  • The next line contains the three space-separated coordinates, p, q, r.

CONSTRAINTS:

  •  T  105
  •   26
  •   107
  •   107
  •  A[i]  z
  •  B[i]  108
  •  C[i]  108
  • a   z
  •   108
  •   108

NOTE: The list of blocks, floors and room numbers are in non - decreasing order.

OUTPUT FORMAT:

  • For each test case, print in a new line, "SNAKE FOUND" if the coordinates exist else, print "DOST HI SAANP HAI", without the quotation marks. 
Sample Input
2
4 5 6
a m y z
5 6 7 8 10
2 4 6 8 10 12
l 7 6
4 4 4
a b c d
1 2 3 4
1 2 3 4
c 2 3
Sample Output
DOST HI SAANP HAI
SNAKE FOUND
Time Limit: 0.5
Memory Limit: 256
Source Limit:
Contributers:
Editor Image

?