def inverse(u, v):
 (u3, v3) = (long(u), long(v))
 (u1, v1) = (1L, 0L)
 while (v3 > 0):
  q = divmod(u3, v3)[0]
  (u1, v1) = (v1, (u1 - (v1 * q)))
  (u3, v3) = (v3, (u3 - (v3 * q)))
 while (u1 < 0):
  u1 = (u1 + v)
 return u1

def inverse ( u , v ) : ( u3 , v3 ) = ( long ( u ) , long ( v ) ) ( u1 , v1 ) = ( 1 L , 0 L ) while ( v3 > 0 ) : q = divmod ( u3 , v3 ) [ 0 ] ( u1 , v1 ) = ( v1 , ( u1 - ( v1 * q ) ) ) ( u3 , v3 ) = ( v3 , ( u3 - ( v3 * q ) ) ) while ( u1 < 0 ) : u1 = ( u1 + v ) return u1
inverse:long return the inverse of u mod v .