You are given an undirected graph G with N vertices. The vertices are numbered 0 through N−1, and one lowercase letter is written on each edge.
A walk is a route that may pass through the same vertex and the same edge more than once. The length of a walk is the number of edges it uses. The value of a walk is the string obtained by concatenating the letters on its edges in the order they are used.
A palindrome is a string that reads the same forward and backward. "a", "abba", and "racecar" are palindromes.
Among the walks that start at vertex 0 and end at vertex 1, find the ones whose value is a palindrome, and report the length of the shortest such walk.