Three soldiers, 34 militants killed in northwest Pakistan: military