Hi @Rahul_Unnikrishnan
I have updated the original post with expected output for both scenario.
Thanks