Knights headed to state tournament after losing heartbreaker to Cosby