Select distinct firstId...
The other two should really be distinct as well, but the chance of duplicates is practically zero.