Before tomato and maize diverged from a common ancestor, the ancestor possessed paleoAP3, which is simpler and more stamen-oriented in its function. This was maintained, though the sequence changed to a degree to give rise to maize. Tomato is the product of a gene duplication leading to modern AP3 in two copies. These have modern petal-forming function, and having two copies of AP3 allows for new functions to evolve in one copy.
Work Step by Step
The thing here is to see the big changes: paleoAP3 to AP3 and the duplication event. Then think about how these change or enhance functions for petal formation.