According to the saving of the momentum, the total momentum before collision is equal to the total momentum after collision
in symbols:
[tex]P_{i1}+P_{i2}=P_{f1}+P_{f2}[/tex]
thus
[tex]10+P_{i2}=(-5)+(-7)[/tex]
then, the initial momentum of the second cart
[tex]P_{i2}=(-7)+(-5)+(10)=-23m/s[/tex]