// Arup Guha
// 6/19/2023
// Solution to Kattis Problem: Class Picture
// https://open.kattis.com/problems/classpicture
// Illustrates going through all permutations via next_permutation.

using namespace std;
#include <bits/stdc++.h>

// Easier if global.
int n;
vector<string> names;
map<string,int> mymap;
vector<vector<bool>> forbidden;

bool go(vector<int>& perm, vector<bool>& used, int k);

int main() {

    // Annoying but this is how they do input.
    while (cin >> n) {

        // Read in names and sort.
        names.clear();
        for (int i=0; i<n; i++) {
            string tmp;
            cin >> tmp;
            names.push_back(tmp);
        }
        sort(names.begin(), names.end());

        // Easy lookup.
        mymap.clear();
        for (int i=0; i<n; i++)
            mymap[names[i]] = i;

        // For forbidden positions.
        forbidden.clear();
        for (int i=0; i<n; i++)
            forbidden.push_back(vector<bool>(n));

        // Store all bad pairs.
        int bad;
        cin >> bad;
        for (int i=0; i<bad; i++) {
            string s,t;
            cin >> s >> t;
            forbidden[mymap[s]][mymap[t]] = true;
            forbidden[mymap[t]][mymap[s]] = true;
        }

        // Set up and solve.
        vector<int> perm(n);
        vector<bool> used(n, false);
        bool hasSol = go(perm, used, 0);

        // No sol case.
        if (!hasSol)
            cout << "You all need therapy." << endl;

        // Output names.
        else {
            for (int i=0; i<n-1; i++)
                cout << names[perm[i]] << " ";
            cout << names[perm[n-1]] << endl;
        }

    }

    return 0;
}

bool go(vector<int>& perm, vector<bool>& used, int k) {

    // It worked!
    if (k == n) return true;

    // Try each value i in slot k.
    for (int i=0; i<n; i++) {

        // Can't do this one skip it.
        if (used[i]) continue;

        // Person i is not friends with person perm[k-1] so also skip.
        if (k>0 && forbidden[perm[k-1]][i]) continue;

        // Place this person in line and recurse.
        used[i] = true;
        perm[k] = i;
        bool tmp = go(perm, used, k+1);

        // If this worked, we stop immediately and return true.
        if (tmp) return true;

        // Undo so we can use i later.
        used[i] = false;
    }

    // If we get here, we hit a dead-end.
    return false;
}
