Power Control and Channel Allocation for D2D Underlaid Cellular Networks