Days of the Week#13105

Days of the Week

0.5 seconds
256 megabytes

Every autumn Ukrainian student teams go through the ICPC season: first the 1/8 stage, then the 1/4 stage, and finally SEERC. This year the three stages took place on three different calendar days: the 1/8 stage was held before the 1/4 stage, and the 1/4 stage before SEERC.

Olena does not remember the dates any more, only the day of the week of each stage. The days of the week repeat in the order monday, tuesday, wednesday, thursday, friday, saturday, sunday, then monday again, and so on.

Help Olena find the minimum possible number of days from the 1/8 stage to SEERC, counting both of these days, that is, the number of days on which the season had already started and had not yet finished.

Input

The first line contains a single integer (1 \le t \le 1000) — the number of test cases.

Each of the next lines contains three words: the days of the week of the 1/8 stage, of the 1/4 stage and of SEERC, in this order. Each word is one of monday, tuesday, wednesday, thursday, friday, saturday, sunday.

Output

For each test case print one integer — the minimum possible number of days from the 1/8 stage to SEERC inclusive.

Examples

Example 1

Loading
Loading

Note

In the first test case the stages could take place on three Mondays in a row, for example on October 5, October 12 and October 19: that is days from the first to the last one inclusive.

In the second test case the stages could have taken place on three consecutive days.

In the third test case the 1/4 stage was at least days after the 1/8 stage (from a Friday to the next Tuesday), and SEERC was at least days after the 1/4 stage (from a Tuesday to the next Saturday), so the answer is 1 + 4 + 4 = 9.