Given a start word, an end word, and a list of allowed words (all of the same length), find the length of the shortest transformation sequence start -> ... -> end where each step changes exactly one letter and every word after start must be in the allowed list (the end word must also be in the list). The length is the number of words in the sequence, counting both endpoints. If no such sequence exists, output 0.
If start equals end, the sequence is just the single word, so the answer is 1.
Input format
Line 1: the start word.
Line 2: the end word.
Line 3: an integer W, the number of allowed words.
Next W lines: the allowed words (all the same length as start).
Output format
One line: the length of the shortest transformation sequence, or 0 if none exists.
Constraints
- 1 <= word length <= 10
- 0 <= W <= 200
- All words are lowercase and share the same length.