I've been initially told that ん is always pronounced like the n in pink. But I've been looking at this wikipedia page: https://en.wikipedia.org/wiki/Help:IPA_for_Japanese#cite_note-stop-2
And it is saying that the ん in words like せんぱい is pronounced as m as in much.
So is there any way to know if I should pronounce ん as n or m in a word?