In details:
I have two train stations, the first outputs "T+train id", the second "U+train id". I also have a list of train ids. I need a circuit setup that checks if a train is on the id list and if it is, the setup should output the signal from the station ("T+train id" or "U+train id") that matches the list. I made a scheme to help understand what I mean:

I can make this setup simply using as many combinators as cases there are, but I want to have a large list of train ids, let's say 30, and many stations, let's say 8. That way I would need 8*30=240 combinators and I would need to set each combinator manually, so that would be really painful, especially, when I'm planning to use this setup as a blueprint with different number of stations and different ids. That's why I need a setup in which I would only change ids on constant combinators and add train stations.
Assumption: Every train has different id, so the same id can't appear on both stations at once (there can't be T268 and U268 at once)