Question concerning the solution of a certain calendar problem involving modular arithmetic. A question I was given is the following:

A certain month on the calendar has 31 days, and it has an equal amount of Mondays and Wednesdays. How many different kind of days(Monday to Sunday) can be the starting day of this month?

I have drawn out each calendar scenario and gotten an answer of 3(Monday, Thursday, and Friday), but the solution gives an easier way:

$31\equiv3\pmod7$, so the week cannot start with Saturday, Sunday, Tuesday or Wednesday as that would result in an unequal number of Mondays and Wednesdays. Therefore, Monday, Thursday, and Friday are valid so the answer is $\boxed {B\ }$. (Source: AMC 12)

I'm perplexed on how this works. How did they jump from $31\equiv3\pmod7$ to "the week cannot start with Saturday, Sunday, Tuesday or Wednesday"? Can someone explain to me how this works? Thanks.
Also, if you replaced Monday and Wednesday in the answer with a different pair of days, would the same approach work? Like will the following question also have an answer of 3?

A certain month on the calendar has 31 days, and it has an equal amount of Tuesdays and Fridays. How many different kind of days(Monday to Sunday) can be the starting day of this month?

 A: It’s definitely not clear to begin a solution with $31\equiv3\pmod7$ without some context, so here's some.
Spoiler: The $3$ is the number of days in the month beyond as many full $7$-day weeks as the month contains. Call those days after as many full weeks in the month “leftover days.”
Two different weekdays appear the same number of times in the month so long as they are either both present or both absent in the “leftover” days. (The leftover days are those, if any, after the first $28$ days, for normal months with between 28 and 31 days.)
In the case of actual calendar months, there are always $4$ full weeks, plus between $0$ and $3$ additional days, but finding out what number modulo $7$ equals the number of days in the month is a completely general approach when there are $7$ days in a week.
So in this case, we first find $31\pmod7$, which is the number of “leftover” days. Of course, these leftover days must be consecutive, so for there to be the same number of Mondays as Wednesdays in three consecutive days, the possibilities are that the days are Monday-Wednesday, Thursday-Saturday, or Friday-Sunday. These are the only three ways the month can end without its having different numbers of Mondays and Wednesdays, so there are exactly three weekdays on which the month can begin. (This last deduction from ways a month can end to ways it can begin takes a bit of thought, but I hope it's not a mystery.)
A: There has to be more to his explanation. Your conclusion of Monday, Thursday and Friday is correct because, in a $31$ day month, the weekdays that correspond to the first, second and third of the month occur five times while the other days of the week occur four times. We can easily see that we can start on Monday, Thursday or Friday because if we start on Monday, both Monday and Wednesday occur five times and if we start on either Thursday or Friday, they both occur four times. In all other cases, they occur a different number of times.
We can apply that same analysis to the case when we require the same number of Tuesdays and Fridays.
We can't start on Sunday, Monday or Tuesday because we would get five Tuesdays but only four Fridays. We can't start on Wednesday, Thursday or Friday because we would get five Fridays but only four Tuesdays. Therefore, we can only start on a Saturday.
Therefore, there is more to this problem than the fact that $31\equiv 3\text{ mod }7$
