Schedule

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Anton goes to school from Monday to Friday. At Anton's school lessons last for 4545 minutes and breaks for 1515 minutes. The first lesson starts at 77 a.m. and the last lesson finishes at 3:45 p.m. It's easy to see that each lesson starts at the beginning of an hour

Anton wants to stay healthy, so he wants to sleep for 88 hours every day. He doesn't always get it, because lessons can start at 77 a.m. Therefore, to sleep in average 8 hours a day on other days he can sleep more than 88 hours, for example, on Saturday and Sunday, when he doesn't go to school. Anton can't sleep more than 1010 hours a day, because otherwise he will feel that he has slept too much and the rest of the day will feel bad. Anton gets up at least an hour before the beginning of the lessons to have a breakfast and get to school. Anton falls asleep at midnight every day.

Anton is a good student, so he wants to be at all lessons in his school. But if one day at a time when he needs to get up to go to school, he has a lack of sleep for at least 55 hours, he will oversleep his first lesson. Anton started to go to school on Monday. Initially Anton he has no lack of sleep, because in summer he had time to rest and sleep.

Help Anton to find out what day he will oversleep his first lesson.

입력

The first line contains kk ---  the number of lack of sleep hours that Anton needs to oversleep his first lesson. (1k10001 \le k \le 1000)

Next five lines contain 99 symbols 00 and 11 characters --- a description of the Anton's school schedule from Monday to Friday. On Saturday and Sunday Anton doesn't go to school. If on the day ii Anton has a lesson with the number jj, then jj-th character in the ii-th row is 11 otherwise it is 00.

출력

If Anton never has lack of sleep and never oversleeps his lessons, output <<-1>>, otherwise output two integers --- number of week and day when Anton will skip his first lesson.

힌트

Every day Anton's lessons last from 7:00 a.m. to 1:45 p.m., so every day he will get up at 66 a.m. and accumulate 22 hours of lack of sleep. By the weekend Anton will accumulate 1010 hours of lack of sleep, but he will be able to compensate for 44 of them, if he sleeps 1010 hours on Saturday and Sunday. Starting the second week with 66 hours of lack of sleep, on Wednesday Anton will overspleep his first lesson.