Cannot figure out how to remove this Using Temporary
There is no chance to remove Using temporary; Using filesort on that query.

If m.id is unique (or even primary key), DISTINCT is excessive. If not, the ORDER BY is random.- Akina