private boolean dfs(HashMap<String, ArrayList<String>> graph, List<String> res, String from, int len) {
        if (res.size() == len) return true;
        if (graph.containsKey(from)) {
            ArrayList<String> tos = graph.get(from);
            for (int i = 0; i < tos.size(); ++i) {
                String to = tos.get(i);
                res.add(to);
                tos.remove(i);
                if (dfs(graph, res, to, len)) return true;
                res.remove(res.size() - 1);
                tos.add(i, to);
            }
        }
        return false;
    }