#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main() {
long long n, z, dir;
long long x = 0, y = 0, ne = 0, se = 0;
double dx, dy;
cin >> n;
while(n--) {
cin >> dir >> z;
switch (dir) {
case 1: y+=z; break;
case 5: y-=z; break;
case 3: x+=z; break;
case 7: x-=z; break;
case 2: ne+=z; break;
case 6: ne-=z; break;
case 4: se+=z; break;
case 8: se-=z; break;
}
}
dx = x + (ne + se)*M_SQRT1_2;
dy = y + (ne - se)*M_SQRT1_2;
cout << fixed << setprecision(3) << dx << " " << dy;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWF0aC5oPgojaW5jbHVkZSA8aW9tYW5pcD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG1haW4oKSB7CiAgICBsb25nIGxvbmcgbiwgeiwgZGlyOwogICAgbG9uZyBsb25nICB4ID0gMCwgeSA9IDAsIG5lID0gMCwgc2UgPSAwOwogICAgZG91YmxlIGR4LCBkeTsKIAogICAgY2luID4+IG47CiAgICB3aGlsZShuLS0pIHsKICAgICAgICBjaW4gPj4gZGlyID4+IHo7CiAgICAgICAgc3dpdGNoIChkaXIpIHsKICAgICAgICBjYXNlIDE6IHkrPXo7IGJyZWFrOwogICAgICAgIGNhc2UgNTogeS09ejsgYnJlYWs7CiAgICAgICAgY2FzZSAzOiB4Kz16OyBicmVhazsKICAgICAgICBjYXNlIDc6IHgtPXo7IGJyZWFrOwogCiAgICAgICAgY2FzZSAyOiBuZSs9ejsgYnJlYWs7CiAgICAgICAgY2FzZSA2OiBuZS09ejsgYnJlYWs7CiAgICAgICAgY2FzZSA0OiBzZSs9ejsgYnJlYWs7CiAgICAgICAgY2FzZSA4OiBzZS09ejsgYnJlYWs7CiAKICAgICAgICB9CiAgICB9CiAgICBkeCA9IHggKyAobmUgKyBzZSkqTV9TUVJUMV8yOwogICAgZHkgPSB5ICsgKG5lIC0gc2UpKk1fU1FSVDFfMjsKICAgIGNvdXQgPDwgZml4ZWQgPDwgc2V0cHJlY2lzaW9uKDMpIDw8IGR4IDw8ICIgIiA8PCBkeTsKICAgIHJldHVybiAwOwp9