Note how the langrangian adds one additional term word, scaled by a value indicating whether that word is aligned in the current position.
because it is only added for those words that are aligned, we can merge this with the log p f j e a j terms in both f and g. we can solve arg max a f (a) + i,j u (k−1) (i, j)y a (i, j) using the standard Viterbi algorithm.