Schedule
Anton is a student at a school where classes run from Monday to Friday. Each lesson lasts 45 minutes, with 15-minute breaks in between. The first lesson begins at 07:00, and the last one concludes at 15:45. Notably, each lesson starts at the top of the hour.
Anton prioritizes his health and aims to get 8 hours of sleep each night. However, due to early school start times, he sometimes falls short. To average 8 hours of sleep per day, he compensates by sleeping more on weekends, when there are no classes. Anton avoids sleeping more than 10 hours a day, as it makes him feel groggy. Additionally, if he doesn't have a sleep deficit, he limits his sleep to 8 hours to engage in other activities. Anton goes to bed at midnight, after completing homework and other tasks. To have breakfast and reach school on time, he wakes up at least an hour before classes start.
As a dedicated student, Anton attends all his classes. However, if he accumulates at least k hours of sleep deficit by the time he needs to wake up for school, he will skip the first lesson of that day. Anton begins the school year on Monday, fully rested with no initial sleep deficit.
Your task is to determine the day on which Anton will miss his first lesson.
Input
The first line contains the integer k — the number of sleep deficit hours Anton needs to accumulate to miss a lesson (1 ≤ k ≤ 1000).
The following five lines each contain 9 characters, either 0 or 1, representing Anton's school schedule from Monday to Friday. If Anton has a lesson on day i at time slot j, the j-th character of the i-th line is 1; otherwise, it is 0.
Output
If Anton will always get enough sleep and never miss a lesson, output «-1». Otherwise, output two integers — the week number and the day number in that week when Anton will miss his first lesson.
Examples
Note
Since Anton's lessons run from 7:00 to 13:45 each day, he wakes up at 6:00 every morning, resulting in a 2-hour sleep deficit daily. By the weekend, he accumulates 10 hours of sleep deficit but can recover 4 hours by sleeping 10 hours on both Saturday and Sunday. Starting the second week with a 6-hour sleep deficit, Anton will miss his first lesson on Wednesday.