• 1
    Input and Output Data
    • Tasks
  • 2
    Conditions
    • Tasks
  • 3
    For Loop
    • Tasks
  • 4
    Strings
    • Tasks
  • 5
    While Loop
    • Tasks
  • 6
    Lists
    • Tasks
  • 7
    Two-Dimensional Arrays
    • Tasks
  • 8
    Dictionaries
    • Tasks
  • 9
    Sets
    • Tasks
  • 10
    Functions and Recursion
    • Tasks
  • к

Занятие 9. Sets

Difficulty level:

Task«Strikes»

The political life of one country is very lively. The country has & nbsp; k & nbsp; political parties, each of which regularly announces a national strike. The days when at least one of the parties announces the strike, provided that it is not Saturday or Sunday (when no one works), they will cause great damage to the country's economy.
rn
I-I, the batch announces the strikes strictly every b_i & nbsp; days, starting from day with the number & nbsp; a_i . That is, the i-th party announces strikes on the days of & nbsp; a_i , & nbsp; a_i + b_i , & nbsp; a_i + 2 * b_i & nbsp; etc. If on some day several parties declares a strike, then this is considered one nationwide strike.
rn
in the calendar of the country n & nbsp; days numbered, starting with a unit. The first day of the year is Monday, sixth and seventh days of the year & nbsp; & mdash; The weekend, the week consists of seven days.
rn
in the first line of the number given n & nbsp; and & nbsp; k . Next is & NBSP; k & nbsp; lines describing the graphs of the strikes. The I-I line contains the numbers & nbsp; a_i & nbsp; and & nbsp; b_i . You need to determine the number of strikes that have occurred in this country during the year.

Input format

two integers are introduced in the first line: n (number of days a year) and K (number of political parties).
In the following k lines, pairs of integers are introduced by A_I and B_I, where A_I is the day of the start of the II batch strikes, and B_I is the interval between the strikes of the i -th party

Output format

Example

Input

14 3
3 3
7 7
2 7

Output

Hint

There will be no clue here, decide for yourself!

main.py
Test 1
Test 2
Test 3
Test 4
Test 5
Test 6
Test 7
Test 8
Test 9
Test 10
Developer’s solution

🎉 Congratulations! 🎉

You did an excellent job with the task! It was a challenging problem, but you found the correct solution. You are one step closer to mastering programming! Keep up the good work, because every stage you pass makes you even stronger.

AD

Advertisement

red-snake blue-snake green-snake

Running your code...

Помощник ИИ

Привет! Я твой помощник по программированию. Задавай любые вопросы по Python, я могу рассказать о функциях, методах, обьяснить то, что тебе не понятно, а так же о текущей задаче!