adds __hash__ method to Factor class