I have some confusions about the procedure of extended EQ

say: gcd(81, 57)=3

here is what I did:

81=1*57+24

57=2*24+9

24=2*9+6

9=1*6+3

6=2*3+0

then I have problems when I do it from way back

**3** = 9 -1(6)

From the line before that, I get 6 = 24 - 2(9), so:

**3** = 9 - 1(24 - 2(9)) = ??

then I have no idea what to do. my friend give me this = 3(9) - 1(24), and I dont know where this comes from.

here is the solution he gave me, and I dont know where are all those underlined numbers come from, second part after the equal sign, how to substitute those numbers.

From the line before that, we see that 6 = 24 - 2(9), so:

3 = 9 - 1(24 - 2(9)) = __3(9)__ - __1(24)__.

From the line before that, we have 9 = 57 - 2(24), so:

3 = 3( 57 - 2(24)) - 1(24) = __3(57)__ - __7(24)__.

And, from the line before that 24 = 81 - 1(57), giving us:

3 = 3(57) - 7( 81 - 1(57)) = __10(57)__ -__7(81)__.

Anyone give me a detailed explain..Thank you. I am struggling.