A farmer had some chickens and some cows . She counted 40 heads and 126 legs . How many chickens and how many cows did she have?