write code for reverse nodes in k group