Each element of people will be a single space-delimited list of positive integers such that:
1) Each positive integer is between 1 and 1000 inclusive with no extra leading zeros.
2) Each element contains the same number of integers.
3) Each element contains at least 2 positive integers.
4) Each element does not contain leading or trailing whitespace.
And I haven't thought about the point you mentioned, i considered only one digit numbers. So, my solution will not scale I guess. I will need to rewrite my code.
I solved above mentioned issue, by rewriting my code as below