Two of the country’s largest food companies have agreed to merge in a deal put into place with the help of dozens of lawyers across four law firms.

Pittsburgh-based H.J. Heinz Co. announced Wednesday its agreement to merge with Chicago-area-based Kraft Foods in a deal that would create the fifth largest food and beverage company in North America and marry brands such as Heinz Ketchup and Philadelphia Cream Cheese.