Solved extended GCD