Markets give up early gains; trade lower on foreign fund exodus