```python
def solution (a, b, n):
    def extended_gcd(a, b):
        if b == 0:
            return a, 1, 0
        g, x1, y1 = extended_gcd(b, a % b)
        x = y1
        y = x1 - (a // b) * y1
        return g, x, y

    if a == 0 and b == 0:
        if n == 0:
            return 0, 0
        else:
            # No solution exists, but the function must return a tuple.
            # This case is ambiguous based on the prompt.
            # Assuming valid inputs where a solution always exists.
            # If a and b are 0, n must also be 0.
            return 0, 0

    g, x_prime, y_prime = extended_gcd(a, b)

    # A solution exists if n is divisible by g.
    # Assuming valid test cases where this is always true.
    if n % g != 0:
        # No solution exists.
        # Again, assuming valid inputs.
        pass

    k = n // g
    x = x_prime * k
    y = y_prime * k

    return x, y
```