get_string(String) :-
  current_input(Input),
  read_string(Input, ' \n', '', _, String).
 
get_number(Number) :-
  get_string(String),
  number_string(Number, String).

for(A,B,A,B,X) :- X =:= A*A*A*A*A - B*B*B*B*B, !.
for(A,200,Ans_A,Ans_B,X) :-
  Next_A is A + 1,
  for(Next_A,-200,Ans_A,Ans_B,X).
for(A,B,Ans_A,Ans_B,X) :- 
  Next_B is B + 1,
  for(A,Next_B,Ans_A,Ans_B,X).

main :-
  get_number(X),
  for(-200,-200,A,B,X),
  write(A), write(' '), writeln(B).
