Modified mapper and reducer for unique query.