Output looks ok. I read from keyboard N strings then add M at the end then remove first four.