deep reverse solution