using System.Collections.Generic;
public class Person : IComparable<Person>
public string Name { get; set; }
public int Age { get; set; }
public string Town { get; set; }
public Person(string name, int age, string town)
public int CompareTo(Person other)
int nameComparison = Name.CompareTo(other.Name);
int ageComparison = Age.CompareTo(other.Age);
return Town.CompareTo(other.Town);
List<Person> people = new List<Person>();
while ((input = Console.ReadLine()) != "END")
string[] personInfo = input.Split();
string name = personInfo[0];
int age = int.Parse(personInfo[1]);
string town = personInfo[2];
Person person = new Person(name, age, town);
int n = int.Parse(Console.ReadLine());
if (n < 0 || n >= people.Count)
Console.WriteLine("No matches");
Person targetPerson = people[n];
foreach (var person in people)
if (person.CompareTo(targetPerson) == 0)
int totalPeople = people.Count;
Console.WriteLine("No matches");
Console.WriteLine($"{equalPeople} {notEqualPeople} {totalPeople}");