Infosys interview question

joins based output