import java.util.*; public class Main { class TreeNode { int val; TreeNode left; TreeNode right; public TreeNode(int val) { this.val = val; } } Map<String, Integer> map = new HashMap<>(); static List<TreeNode> r...