Flights

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

문제

In Republic of JOI, there are NN airports numbered from 00 to N1N - 1. There are N1N - 1 airline routes numbered from 00 to N2N - 2. The airline route ii (0iN20 ≤ i ≤ N - 2) connects the airport U_iU\_i and the airport V_iV\_i bidirectionally. It is possible to travel from any airport to any other airport by connecting several airline routes. For every airport, there are at most 33 airline routes connecting it with another airport.

Benjamin is planning to take a trip in Republic of JOI. On the last day of the trip, he wants to arrive at the airport where the hot spring is located. The amusement park is located at the airport xx, and the hot spring is located at the airport yy. Since Benjamin does not know anything about the airline routes, he will communicate with Ali, a staff of the airplane company. Benjamin wants to know the minimum number of airline routes he has to take to travel from the airport where the amusement park is located to the airport where the hot spring is located. Ali knows information of the airplane routes. But Benjamin does not know which airline routes he has to take.

  1. Ali sets an ID code for each airport. An ID code is an integer between 00 and 2N+192N + 19, inclusive.
  2. Benjamin gets the ID code XX of the airport where the amusement park is located, and the ID code YY of the airport where the hot spring is located.
  3. Benjamin sends an e-mail message to Ali. The message is a string whose length is exactly equal to 2020. Every character of the message is either 00 or 11.
  4. Ali writes a letter to Benjamin. The letter contains a string whose length is between 11 and 300,000300\\,000, inclusive. Every character of the letter is either 00 or 11.

Write programs which implement the strategy of Ali, a staff of the airplane company, and the strategy of Benjamin, a traveler. Note that in Step 2, Benjamin can get the ID codes XX, YY of the airports where the amusement park and the hot spring are located. However, Benjamin cannot get the airport numbers xx, yy.

제한

  • 1Q501 ≤ Q ≤ 50.
  • 2N10,0002 ≤ N ≤ 10\\,000.
  • 0U_i<V_iN10 ≤ U\_i < V\_i ≤ N - 1 (0iN20 ≤ i ≤ N - 2).
  • 0xN10 ≤ x ≤ N - 1.
  • 0yN10 ≤ y ≤ N - 1.
  • xyx \ne y.
  • It is possible to travel from any airport to any other airport by connecting several airline routes.
  • For every airport, there are at most 33 airline routes connecting it with another airport.