compute argmax directly, but we can compactly represent all paths as a graph < 3 ↑, 1 ↑> < 5 ↓, 10 ↓> < 5 ↑, 6 ↓> < 4 ↑, 3 ↓> < 11 ↓> < 3 ↓> < 5 ↓, 8 ↓> < 2 ↑> < 10 ↑> < 8 ↑> < 8 ↓> < 9 ↑, 5 ↑> < 6 ↑, 5 ↓> < 6 ↑> < 6 ↑, 7 ↓> < 10 ↑, 11 ↓> < 7 ↑> < 4 ↓, 5 ↓> < 11 ↑> < 9 ↑> < 11 ↑, 5 ↑> < 2 ↑, 4 ↓> < 4 ↓, 6 ↓> < 5 ↑, 4 ↑> < 10 ↓> < 6 ↓> < 7 ↑, 4 ↑> < 7 ↓> < 5 ↑, 7 ↓> < 3 ↑> < 9 ↓> < 8 ↑, 9 ↓> Graph is linear in the size of the grammar • Green nodes represent leaving a word • Red nodes represent entering a word • Black nodes are intermediate paths