Rick love Unity but Mr Meeseeks love Unity Rick Mr Meeseeks love rival Unity love rap decide compete rap game battle order choose good Rick nerd instead he s go to verse run original algorithm lyric Rap God song his algorithm little bit complicated he s tree n vertex number 1 n there s lowercase english letter write edge he denote strab string write character edge short path b string length equal distance b note strab reverse strba straa in order good verse need answer query he s computer scientist able answer query ask help each query characterize vertex x y xy Answer query number vertex like z zxzy strxy lexicographically large strxzstre xx1x2xx lexicographically large string yy1y2yy xy x1y1x2y2xyyy exist number r rxry x1y1x2y2xryr xr1yr1 character compare like ascii code alphabetic orderHelp Rick girl gender Unity