TokenName - splitting name

I have a scenario where I’m locking two tokens in the smart contract.
Let’s say that I lock

  1. Two tockens that are allowed to generate a new one:
    MyTokenG1A00001 and MyTokenG1A00002 → such pair in the validation logic would be true because they have a common base MyTokenG1A

  2. Two tockens that are not allowed to generate a new one:
    MyTokenG1A00001 and MyTokenG2A00002 → such pair in the validation logic would return false because they don’t have a common base MyTokenG1A and MyTokenG2A

is it possible without passing extra information into datum ?
or maybe it is memory and cpu more efficient to actually pass this information in datum?