`precedence[i][j]` is used multiple times.  Please put it in a variable.