Photoinduced transition from Mott insulator to metal in the undoped cuprates Nd2CuO4and La2CuO4