compare by int and use defaultdict