use python set and dictionary