import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

public class l5 {

    Scanner in = new Scanner(System.in);
    
    // object for sample 1
    public class person implements Comparable<person>{
        int height = 0;
        String name = "Joe";
        public person(){};
        public person(int h, String s) {
            height = h; name = s;
        }
        public int compareTo(person p) {
            if (height != p.height) return height - p.height;
            else return (name.compareTo(p.name));
        }
        public boolean equals(person a) {
            return (a.height == height) && (a.name.equals(name));
        }
    }
    
    void problem1() {
        ArrayList<person> list = new ArrayList<person>();
        while(in.hasNextInt()){
            int h = in.nextInt();
            String n = in.next();
            list.add(new person(h, n));
        }
        Collections.sort(list);
    }
    
    // recursive function for sample 2   
    char[] word;
    boolean[] used;
    char[] buffer;
    
    boolean isGoodWord(String s) {
        // provided
        return true;
    }
    void recurse(int pos) {
        // if we've got a candidate word, check it
        if (pos == word.length) {
            String candidate = new String(buffer);
            if (isGoodWord(candidate))
                System.out.println(candidate);
        }
        else {
            // try all possibilities in this position
            // can't use letters we already used though
            for(int i = 0; i < word.length; i++) if (!used[i]) {
                used[i] = true;
                buffer[pos] = word[i];
                recurse(pos+1);
                used[i] = false;
            }
        }
    }

    void problem2() {
        String w = in.next();
        word = w.toCharArray();
        used = new boolean[word.length];
        buffer = new char[word.length];
        recurse(0);
    }
    
    
    // sample problem 3
    // sort word, and use map
    
    void problem3() {
        HashMap<String, String> map = new HashMap<String, String>();
        while(in.hasNext()) {
            String problem = in.next();
            String answer = in.next();
            char[] rep = problem.toCharArray();
            Arrays.sort(rep);
            map.put(new String(rep), answer);
        }
        while(in.hasNext()) {
            String newProblem = in.next();
            char[] rep = newProblem.toCharArray();
            Arrays.sort(rep);
            String repString = new String(rep);
            if (map.containsKey(repString)) {
                System.out.println(map.get(repString));
            }
            else {
                System.out.println("I am stumped");
            }
        }
    }
}
