John Doe decide mathematical object name so invent Doe graph the Doe graph family undirecte graph characterize single nonnegative number order well denote graph order k Dk denote number vertex graph Dk Dk then let define Doe graph follow D0 consist single vertex number 1 d1 consist vertex number 1 2 connect edge Dn n2 obtain graph dn1 dn2 Dn1 dn2 join graph number vertices graph dn2 increase dn1 example vertex number 1 graph dn2 vertex number 1dn1 after edge add graph go vertex number dn1 dn11 second go vertex number dn11 1 note definition graph Dn imply Dn connect graph vertex number 1 Dn the picture show Doe graph order 1 2 3 4 leave right John think Doe graph great exist polynomial algorithm search hamiltonian path however task answer query find shortestlength path vertex ai bi graph DnA path pair vertice u v graph sequence vertex x1 x2 xk k1 x1u xkv ik vertex xi xi1 connect graph edge the length path x1 x2 xk number k1