Mapping categorical data in K-nearest neighbour
You can map M to 0 and F to 1.  In general, if you have N categories, you can map each category to a number in the range 1,2,..,N.  If N=2, this is fine for a k-nearest neighbor classifier.

If N>2, this is not a good idea for a k-nearest neighbor classifier, as it makes some assumptions (e.g., that the first category is more similar to the second category than the third).  If you want to use a k-nearest neighbor classifier and you have no knowledge about the meanings of the categories, the best you can do is to use a one-hot encoding.  If you do have some knowledge about the meanings of the categories, the best you can do is to define a distance function or similarity function between categories, and use that directly (instead of mapping the categories to numbers).