In the last episode of Person of Interest, we see that Harold decides to go on top of a building to upload the Machine's copy on a satellite. He knows that whoever uploads the copy of the Machine will be dead as Samaritan is launching the missle. But finally when he reached the top, we see he is on the wrong building and is saved. Instead of him, John is on the actual building's roof and dies there. John reveals he had a deal with the Machine and the Machine also confirms the same.
(Finch on building with Machine/Root voice)
Finch: Wait, are you sure this is the right place? Yes.
Root: This is where you're supposed to be.
Finch: No, none of these dishes are capable of transmitting to a Molniya orbit. This is the wrong building.
(On other building, Reese is standing)
Reese: Right building, Finch. For you.
Finch: What are you doing?
Reese: Me and the Machine have had a long-standing arrangement. A deal. Told you. Pay you back all at once. That's the way I like it.
Finch: No, I told you. It's supposed to be me alone.
Root/Machine: Sorry, Harry. Deal's a deal. You know as well as I do that he wasn't gonna let you die.
What was that deal or arrangement? And when did John and the Machine decide it?