Hello Priyanka! To replicate the test case I have kept one exam that is associated with multiple students and while editing or creating a new student one is going to select exam as well so the domain model setup will look something like this (make changes according to your need)
While creating template you need to take exactly same attribute as you have in your domain model(with no space or comma) I am attaching screenshot of all three tabs.
I hope am able to answer your question! Thank You