#include <bits/stdc++.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
using namespace std;
int sgn (int a) {
return (a > 0) - (0 > a);
}
void interactor () {
srand (time(NULL));
int bound = (1 << 30);
int a = rand() % bound;
int b = rand() % bound;
int asked_questions = 0;
char type;
int c, d;
while (1) {
cin >> type >> c >> d;
asked_questions++;
if ((type != '?' && type != '!') || c < 0 || d < 0 || bound <= c || bound <= d) {
cerr << "Incorrect question." << endl;
break;
}
if (type == '?') {
if (asked_questions == 63) {
cerr << "To many questions." << endl;
break;
}
cout << sgn ((a ^ c) - (b ^ d)) << endl;
}
else {
if (a == c && b == d)
cerr << "Correct solution." << endl;
else
cerr << "Incorrect solution." << endl;
break;
}
}
}
int main () {
char * que = "/tmp/que";
char * ans = "/tmp/ans";
mkfifo(que, 0777);
mkfifo(ans, 0777);
pid_t pid = fork();
if (pid < 0)
return 1;
if (pid == 0) {
int fd_read = open (ans, O_RDONLY);
int fd_write = open (que, O_WRONLY);
dup2 (fd_read, 0);
dup2 (fd_write, 1);
execl ("solution", "solution", NULL);
}
else {
int fd_write = open (ans, O_WRONLY);
int fd_read = open (que, O_RDONLY);
dup2 (fd_read, 0);
dup2 (fd_write, 1);
interactor ();
}
unlink (que);
unlink (ans);
return 0;
}