In order to keep track of these values, it is necessary to augment each node in the tree to be d = s, l, c, c + 1, r, tl, tr with two additional values tl and tr that indicate the position of the leftmost and rightmost words after reordering.
a straight nonterminal parent d with children d l = s l , l, lc, lc+  1, c, tl, tlr and d r = s r , c+1, rc, rc+1, r, trl, tr will have loss as follows with a similar calculation being possible for inverted non-terminals.