The 7458 contains two separate sum-of-products sections. The functional sketch places the AND and OR operations inside a chip outline; it shows the logic relationship, not a physical package pinout.
Interface
Drive p1y with (p1a and p1b and p1c) or (p1d and p1e and p1f). Drive p2y with (p2a and p2b) or (p2c and p2d). Keep the two sections independent.