// Arup Guha
// 2/18/2024
// Solution to Kattis Problem: Class Picture
// https://open.kattis.com/problems/classpicture

import java.util.*;

public class classpicture {

	public static int n;
	public static String[] names;
	public static HashMap<String,Integer> map;
	public static boolean[][] conflict;
	
	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		
		while (stdin.hasNext()) {
			
			// Read in number of students.
			n = stdin.nextInt();
			
			// Get and sort the names.
			names = new String[n];
			for (int i=0; i<n; i++)
				names[i] = stdin.next();
			Arrays.sort(names);
			
			// Now map the names to their codes.
			map = new HashMap<String,Integer>();	
			for (int i=0; i<n; i++) 
				map.put(names[i], i);
				
			// Store conflicts.
			int nC = stdin.nextInt();
			conflict = new boolean[n][n];
			
			// Read conflict pairs.
			for (int i=0; i<nC; i++) {
				
				// Get corresponding indexes.
				int idx1 = map.get(stdin.next());
				int idx2 = map.get(stdin.next());
				
				// Mark it.
				conflict[idx1][idx2] = true;
				conflict[idx2][idx1] = true;
			}
			
			int[] perm = new int[n];
			boolean[] used = new boolean[n];
			
			boolean res = go(perm, used, 0);
			
			// No case.
			if (!res)
				System.out.println("You all need therapy.");
			
			// Print names.
			else {
				
				// Print list.
				for (int i=0; i<n-1; i++)
					System.out.print(names[perm[i]]+" ");
				System.out.println(names[perm[n-1]]);
			}
		}
	}
	
	public static boolean go(int[] perm, boolean[] used, int k) {
	
		if (k == perm.length) return true;
		
		// Run permutation algorithm.
		for (int i=0; i<perm.length; i++) {
		
			// Used this already.
			if (used[i]) continue;
			
			// Can't put this kid here because he doesn't get along with the previous person.
			if (k>0 && conflict[i][perm[k-1]]) continue;
			
			// Mark it and go.
			perm[k] = i;
			used[i] = true;
			boolean res = go(perm, used, k+1);
			
			// If this worked, stop and return true.
			if (res) return true;
			
			// Unmark and try next.
			used[i] = false;
		}
		
		// If we get here no permutation worked.
		return false;
	}
}