You are given a string and you have to tell whether it is can be generated by the tour.
Simply iterate over the string and move through corresponding cities.
When you process the given string jump in between the cities according to the current character. If at the end of the string If the tour ends at the green city output YES.
You may notice that only the strings ending with ‘1000’ are accepted.