# a * x + b * y = gcd(a, b)
def egcd(a: int, b: int) -> (int, int, int):
    if a == 0:
        return b, 0, 1
    else:
        gcd, x, y = egcd(b % a, a)
        return gcd, y - (b // a) * x, x


if __name__ == '__main__':
    print(egcd(50, 30))

# a * x + b * y = gcd(a, b)
def egcd(a: int, b: int) -> (int, int, int):
    if a == 0:
        return b, 0, 1
    else:
        gcd, x, y = egcd(b % a, a)
        return gcd, y - (b // a) * x, x


if __name__ == '__main__':
    print(egcd(50, 30))

# a * x + b * y = gcd(a, b)