Optimal resource allocation in distance-adaptive few-modes backbone networks with flexible grid