Merge legend into the first cells of the table.