Match time series' colors based on label

I’m using Grafana v10.4.2. I have two queries, one for memory usage, the other for memory limit. Each returns an unknown number of time series, one for each container. I want to achieve something like the following picture:

I can easily set the limits to be dashed using field overrides. But can I make it so that the specific container’s usage and limits are the same color? I’d like to match them using a label value. I don’t know how many containers there are beforehand.

Thanks!