awk '{l++;gsub("!","");t[1]=4;t[4]=2;t[9]=3;o=$1;for(i=2;i<=NF;i++){o=o " " $i (i==t[l]?"!":"")};print o}' war_and_peace.txt