Jack paid $7 for each adult ticket and $4 for each child ticket. Jack spent a total of $40 for the tickets. How many adult tickets did he buy? How many child tickets did he buy?