Dima love Inna he decide write song Dima magic guitar n string m fret Dima make guitar produce sound like play note need hold string fret pull string when Dima pull ith string hold jth fret guitar produce note let denote aij we know Dimas guitar produce k distinct note it possible note produce multiple way in word possible aijapq ijpqDima write song sequence s note in order play song need consecutively produce note song guitar you produce note available way Dima understand way play song want play song look complicated possible try act like CobeinWell represent way play song sequence pair xiyi 1is xith string yith fret produce ith note song the complexity move pair x1y1 x2y2 equal the complexity way play song maximum complexity move adjacent pairshelp Dima determine maximum complexity way play song the guy get to look cool