Masc: ending consonant, й, ь
Fem: ending а, я, ь (note that both masc and fem can end 'ь', these you just have to learn)
Neut: ending о, е

And of course, there are always exceptions to these...