in row domino topsi bottomsi represent half ith domino a domino tile number 1 6 half tileWe rotate ith domino topsi bottomsi swap valuesreturn minimum number rotation value top value bottom sameif return 1 Example 1input top 212422 bottom 526232output 2explanation the figure represent domino give top bottom rotationsIf rotate second fourth domino value row equal 2 indicate second figureexample 2input top 35123 bottom 36334output 1explanation in case possible rotate domino row value equal Constraints2 topslength 2 104bottomslength topslength1 topsi bottomsi 6