Doodle1 is an online tool for scheduling activities (meetings, parties, …) that need to be attended by several people. All participants are polled to indicate on a calendar when they are available, so that the coordinator of the activity can fix a time and date for the activity that meets everyone's availabilities.

Doodle
Example of a doodle where three people have already indicated their availabilities for the first fortnight of December 2013. All participants are free for the first time on Monday December 2, 2013, and from Thursday December 5th all participants are available for the first time for two successive days.

Assignment

A text file contains the information of a doodle where $$m$$ people have indicates their availabilities for $$n$$ successive days. The file contains $$m$$ lines, where each line describes the availabilities of a single person. Each line contains $$n$$ letters that indicate whether (letter V) or not (letter X) that person $$n$$ is available on each of the successive days. The doodle that is graphically represented above is thus stored in a text format using the following format:

VVVXVVXXXXXXVV
XVVXVVXXXXXXVV
VVXXVVXXXXXXVV

Write a function activity that can be used to schedule an activity based on a filled up doodle. The location of the text file containing the information of the doodle must be passed as the first argument to the function. The function also has a second optional parameter days, that indicates how many days the activity lasts. If no explicit value is passed for this parameter, a one-day activity is assumed.

Based on the provided information, the function must look for the first period (spanning the given number of successive days) where all participants of the activity are available. If such a period has been found, the function must return the index of the first day of the period (doodle columns represent successive days, indexed from 1). If no such period was found, the function must return the value -1.

Example

In the following interactive session we assume that the text files doodle1.txt2 and doodle2.txt3 are located in the current directory.

>>> activity('doodle1.txt')
2
>>> activity('doodle1.txt', 2)
5
>>> activity('doodle2.txt', 3)
-1