A total of 52 dogs and cats were on the ranch. If three times the number of dogs exceeded the number of cats by four, how many of each were on the ranch?