To protect user privacy and combined with mobile edge computing, hierarchical federated learning (HFL) is proposed. In HFL, we investigated the aggregated model quality maximization problem. Since the global model quality is influenced by the local model quality, we transformed the aggregated model quality maximization into the sum of local model quality maximization. And we proposed the model quality maximization mechanism MaxQ based on matching game to select high quality mobile devices. In MaxQ, the allocation of mobile devices to each edge server is realized so that the sum of the local model quality is maximized. And we proved that MaxQ has a $\frac{1}{2}$-approximation ratio. Finally, through a large number of simulation experiments, compared with FAIR and EHFL, the model quality of MaxQ is improved by 10.8% and 12.2%, respectively.