Software AG Interview Question

balls, trains and some maths puzzles