Similar Items: Complete and tractable machine-independent characterizations of second-order polytime