Transform data - config from query results

Hi, I am trying to achieve a color mapping for fields.
I have two queries, A and B. A is the data, and B is the key-color two-column table. I have applied grouping to the Matrix for query A. It plots normally, but I now want to assign colors from my query B. I have tried value mapping, but it would not work because my key(B) matches the fields(A). So it is not a value mapping, but there is no field mapping tool. So I wonder how I should do it.
I have set this setting for my config and it works. It turns all my legends into different the same colors. Now, the problem is how I map the color from the key(B) to fields(A). Also, I do not want to apply them manually, as I am doing this as a way to standardize all the colors for all dashboards in my Grafana. I can imagine how painful it is to manually do all this mapping.

Thanks in Advance for your help!!!