You're looking for a number q that is 4 more than a multiple of 12, and 5 more than a multiple of 7.
12 is larger, so satisfy that condition first: the first number 4 more than a multiple of 12 is 4. Now, repeatedly add 12 to your number until you hit on something that is 5 more than a multiple of 7. Since you're adding 12, this will always preserve your original remainder.
Adding 12 gives 4, 16, 28, 40, and 40=5•7+5. So 40 is the smallest positive number satisfying your conditions.