Add column base on same name of second column

HI Guys,

I have input file A.txt

1 AAA
1 BBB
1 1SW
1 2SW
1 3SW
1 BBB
1 PPP
1 1SW
1 PPP
1 1WS
1 1AS
1 P1P
1 AAA

I want Output base on same name in column B and that name at column C

Output.txt

 1 AAA AAA  
 1 BBB BBB  
 1 1SW BBB  
 1 2SW BBB  
 1 3SW BBB  
 1 BBB BBB  
 1 PPP PPP  
 1 1SW PPP  
 1 PPP PPP  
 1 1WS AAA  
 1 1AS AAA  
 1 P1P AAA  
 1 AAA AAA  
 

Between Both AAA and AAA all column have AAA but in inner loop all Column have PPP Between PPP same as BBB.

awk '{if($2 !~ /[0-9]/) {$3 = $2}; a[NR] = $0}
  END {for(i = NR; i >= 1; i--)
    {split(a, b, FS);
 if(b[3] != "") {t = b[3]};
 c = (b[1] FS b[2] FS t)}; delete a;
 for(i = 1; i <= NR; i++) print c}' A.txt

---------- Post updated at 02:46 AM ---------- Previous update was at 02:15 AM ----------

even this code will work

awk '{a[NR] = $0}
  END {for(i = NR; i >= 1; i--) {split(a, p, FS);
    if(p[2] !~ /[0-9]/) {c = p[2]};
 b = (a FS c); delete a};
    for(i = 1; i <= NR; i++) {print b}}' file