// Arup Guha
// 7/22/2026
// Solution to 2006 UCF High School Programming Contest Problem: Phish Phinder

/***
    I started this problem in 2014 and it's the one that made me give up my quest to
    solve all the UCF HS problems. I promised myself that one day I would come back
    to the quest. I started last Monday with this project (9 days ago), and first
    solved the 1994, 1995 and 1998 sets, leaving this one problem for last (except
    for 1989 - 1992 for which I need to both solve the problems and make data.
    Finally, after fighting with the problem some more (last night and today), I
    at least match all of the test data. That doesn't mean this is correct, but there
    are some nasty test cases, so it's at least close enough that I am going to post
    it. There was one key thing I misunderstood back in 2014, which was that you can't
	pre-process by removing all white space. The text is actually allowed to have white
	space and that can make the difference in the end answer. My 2014 solution 
	automatically removed whitespace before starting to solve the problem, which
	automatically made it fail a couple of cases. Thus, I changed the method delWhSp
	so that it doesn't delete ALL white space, but only white space that can't change
	the end answer. Namely, I leave white space that is in the text of links that isn't
	leading or trailing whitespace. The other key fix was changing one of my '\\' to '/'
	as I has previously just flipped that in one place in the code.
***/

import java.util.*;
import java.io.*;

public class phishy {

	public static void main(String[] args) throws Exception {

		Scanner stdin = new Scanner(System.in);
		int numCases = Integer.parseInt(stdin.nextLine().trim());

		// Go through each case.
		for (int loop=1; loop<=numCases; loop++) {

			// Read in message data.
			StringTokenizer tok = new StringTokenizer(stdin.nextLine());
			tok.nextToken();
			String from = tok.nextToken();
			tok = new StringTokenizer(stdin.nextLine());
			tok.nextToken();
			int numLines = Integer.parseInt(tok.nextToken());

			// Read in message.
			/*** \n are very important can't get rid of them ***/
			String msg = "";
			for (int i=0; i<numLines-1; i++)
				msg = msg + stdin.nextLine()+"\n";
			msg = msg + stdin.nextLine();

			// Solve and output.
			if (solve(msg)) System.out.println("Mail from "+from+" looks phishy!");
			else          System.out.println("Mail from "+from+" looks ok.");
		}
	}

	// Returns true iff msg is phishy.
	public static boolean solve(String msg) {

		// This gets rid of white space that doesn't matter, leaving white space that does.
		msg = delWhSp(msg);

		// Find Next Tag.
		int[] next = findNextTag(msg, 0);

		// Keep on going until there are no more tags to look at.
		while (next != null) {

			// Watch out!
			if (bad(msg, next)) return true;
			
			// Go to next.
			next = findNextTag(msg, next[1]+1);
		}

		// Never found a phishy link.
		return false;
	}

	/*** Some white space can be deleted and some can not ***/
	public static String delWhSp(String msg) {
		
		// All non-white space is relevant. 
		boolean[] use = new boolean[msg.length()];
		for (int i=0; i<use.length; i++) {
			char c = msg.charAt(i);
			if (c != ' ' && c != '\n') use[i] = true;
		}
		
		// We do a second sweep through the string to add true for characters
		// that must be included (text).
		int i = 0;
		while (i < use.length) {
			
			// Finds next "<a"
			while (i<use.length-1 && !msg.substring(i,i+2).equals("<a")) i++;
			
			// Get out.
			if (i >= use.length-1) break;
			
			// Finds end of link.
			while (i<use.length && msg.charAt(i) != '>') i++;
			
			// Finds end of text.
			int j = i;
			while (j<use.length-3 && !msg.substring(j,j+4).equals("</a>")) j++;
			int updateI = j;
			
			// Trims white space from left end of text.
			i++; while (i<j && (msg.charAt(i) == ' ' || msg.charAt(i) == '\n')) i++;
			
			// Trims white space from right end of text.
			j--; while (j>i && (msg.charAt(j) == ' ' || msg.charAt(j) == '\n')) j--;
			
			// This whole thing gets marked since we do want its whitespace.
			for (int z=i; z<=j; z++) use[z] = true;
			
			// So we advance.
			i = updateI; 
		}
		
		// At the end we can form the string the way we want. Sorry this is slow!
		String res = "";
		for (int z=0; z<use.length; z++)
			if (use[z])
				res = res + msg.charAt(z);
		return res;
	}
	
	// Returns the indexes (start and end) into the next tag starting at index start.
	public static int[] findNextTag(String msg, int start) {

		int[] ans = null;
		
		// Start from index start...
		for (int i=start; i<msg.length()-1; i++) {
			
			// This is the start of a tag.
			if (msg.charAt(i) == '<' && msg.charAt(i+1) == 'a') {
				
				// Store answer here.
				ans = new int[2];
				ans[0] = i;
				int j = i+2;
				
				// We just have to look for 2 of these...
				while (msg.charAt(j) != '>') j++;
				j++;
				while (msg.charAt(j) != '>') j++;
				ans[1] = j;
				return ans;
			}
		}

		// If we get here there is none.
		return ans;
	}
	
	// Returns true if the link/text delineated by the indexes in next into msg
	// are phishy.
	public static boolean bad(String msg, int[] next) {

		// Get domain
		String tag = msg.substring(next[0]+8, next[1]+1);

		// Doing this only because data doesn't follow the spec. According to the spec,
		// http:// should always be there.
		String domain = tag;
		if (domain.substring(0,7).equals("http://")) domain = domain.substring(7);
		
		// Goes to the next forward slash to get domain.
		int index = 0;
		while (index < domain.length() && domain.charAt(index) != '/' && domain.charAt(index) != '\"') index++;
		domain = domain.substring(0, index);
		
		// Finds end of hyperlink.
		StringTokenizer tok = new StringTokenizer(msg.substring(next[0], next[1]+1), ">");
		tok.nextToken();
		
		// Here is where the text is.
		String text = tok.nextToken("<").trim();
		text = text.substring(1);

		// Farm off the work to compare.
		return compare(domain, text);
	}

	// Returns true if text is valid text using their rules exactly.
	public static boolean validText(String text) {

		boolean flag = false;
		for (int i=0; i<text.length(); i++) {

			// Must have at least one period and letters on both sides.
			if (text.charAt(i) == '.') {
				flag = true;
				if (i == 0 || i == text.length()-1) return false;
				if (!Character.isLowerCase(text.charAt(i-1))) return false;
				if (!Character.isLowerCase(text.charAt(i+1))) return false;
			}

			// Only lowercase letters and periods allowed.
			else if (!Character.isLowerCase(text.charAt(i)))
				return false;
		}

		// Is true iff there was one or more periods and letters on both sides of each.
		return flag;
	}

	// Returns true if domain and text are both valid and inconsistent.
	public static boolean compare(String domain, String text) {

		// Screen these out.
		if (!isDomain(domain)) return false;
		if (!validText(text)) return false;

		// We must compare from the end.
		int i = domain.length()-1, j = text.length()-1;
		
		// So we know when to stop.
		int periodCnt = 0;
		
		// Stop at beginning...
		while (i >= 0 && j >= 0) {

			// We made it, enough characters matched.
			if (periodCnt == 2) return false;

			// This is phishy!
			if (domain.charAt(i) != text.charAt(j))
				return true;
			
			// Update indexes and period count if necessary.
			else {
				if (domain.charAt(i) =='.') periodCnt++;
				i--;
				j--;
			}
		}

		// Weird case where substring works, but actual string in domain continues.
		if (i >= 0 && j < 0) return domain.charAt(i) != '.';

		// Has to be a perfect match, can't run out of the real domain.
		// Check this with incomplete2 vs. lots of links
		if (i < 0 && j >= 0 && text.charAt(j) != '.') return true;

		// Otherwise, just check that there was a period in both.
		return periodCnt < 1;
	}

	// Returns true if s is a valid domain.
	public static boolean isDomain(String s) {

		// Easy check.
		if (!s.contains(".")) return false;
		
		// No go through each character.
		for (int i=0; i<s.length(); i++) {
			
			// Rules for dots...
			if (s.charAt(i) =='.') {
				if (i > 0 && s.charAt(i-1) == '.') return false;
				if (i == 0 || i == s.length()-1) return false;
			}
			
			// Otherwise, only lowercase letters only.
			else if ('a' > s.charAt(i) || s.charAt(i) > 'z') return false;
		}
		
		// Good if we make it here.
		return true;
	}
}