import java.io.*;
import java.util.*;

public class joust_mb_sorting {
    static void close(boolean[][] less) {
        for (int k = 0; k < 26; ++k) {
            for (int i = 0; i < 26; ++i) {
                for (int j = 0; j < 26; ++j) {
                    less[i][j] |= less[i][k] && less[k][j];
                }
            }
        }
    }

    public static void main(String[] args) throws IOException {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            int n = Integer.parseInt(in.readLine());
            boolean[][] less = new boolean[26][26];
            for (int i = 0; i < n; ++i) {
                String line = in.readLine();
                if (line.charAt(2) == '<') {
                    less[line.charAt(0) - 'a'][line.charAt(4) - 'a'] = true;
                } else {
                    less[line.charAt(4) - 'a'][line.charAt(0) - 'a'] = true;
                }
            }
            close(less);
            for (int i = 0; i < 26; ++i) {
                if (less[i][i]) {
                    System.out.println("IMPOSSIBLE");
                    return;
                }
            }
            // to make the total ordering consistent with partial ordering,
            // one need to really try hard
            for (int i = 0; i < 26; ++i) {
                for (int j = i + 1; j < 26; ++j) {
                    if (!less[i][j] && !less[j][i]) {
                        less[i][j] = true;
                        close(less);
                    }
                }
            }

            String word = in.readLine();
            Character[] chars = new Character[word.length()];
            for (int i = 0; i < chars.length; ++i) {
                chars[i] = word.charAt(i);
            }
            Arrays.sort(chars, (l, r) -> {
                if (less[l - 'a'][r - 'a']) return -1;
                return less[r - 'a'][l - 'a'] ? 1 : 0;
            });
            for (int i = 0; i < chars.length; ++i) {
                System.out.print(chars[i]);
            }
            System.out.println();
        }
    }
}
