费尽心思

费尽心思 (fèi jìn xīn si)
to rack one's brains (idiom); to take great pains to think sth through