Function performing calculations .
def solve ( arr ) : NEW_LINE INDENT global ans NEW_LINE i = 0 NEW_LINE while ( i < p ) : NEW_LINE INDENT q = arr [ i ] [ 0 ] NEW_LINE h = arr [ i ] [ 1 ] NEW_LINE t = arr [ i ] [ 2 ] NEW_LINE cd [ q ] = h NEW_LINE wt [ q ] = t NEW_LINE rd [ h ] = q NEW_LINE i += 1 NEW_LINE DEDENT a = [ ] NEW_LINE b = [ ] NEW_LINE c = [ ] NEW_LINE DEDENT