An inverse problem in nonholonomic dynamics