Use a `collections.DefaultDict` here, and you won't have to use `setdefault` later.