Replaced unordered_set with set. Some weird template stuff for randrange