where does the phrase hat trick come from