Influence Functions for Efficient Data Selection in Reasoning