#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define si set<int>
#define qi queue<int>
#define sti stack<int>
#define fi first
#define se second
#define pb push_back
const int N=10000000+5;
vector<ll>v;
ll calc(ll x,ll lim){
ll l=1,r=lim;
while(l<r){
ll mid=(l+r+1)/2;
if (mid*mid<=x)l=mid;
else r=mid-1;
}
return l;
}
int main(){
freopen ("pell.in","r",stdin);
freopen ("pell.out","w",stdout);
ll n;scanf("%lld",&n);
for (ll i=1;i<n;i++){
if (i*i%n==1)v.pb(i);
}
for (ll k=0;;k++){
ll y,s,b;
for (int i=0;i<v.size();i++){
b=v[i];
y=n*k*k+2*k*b+(b*b-1)/n;
s=calc(y,k*n+b);
if (s*s==y&&s>0&&k*n+b>0){
printf("%lld %lld\n",k*n+b,s);return 0;
}
}
}
printf("genshin\n");
return 0;
}