Nifty, Sensex end higher, trim weekly losses as IT, FMCG stocks rally