#pragma GCC target("avx2") #pragma GCC optimize("Ofast") #include #include #include #include using namespace std; using namespace __gnu_pbds; using ll=long long; using ull=unsigned long long; using ld=long double; using pii=pair; using pll=pair; using pli=pair; using pil=pair; using pdd=pair; using vi=vector; using vpi=vector; using vl=vector; using vs=vector; using vc=vector; using vd=vector; using vpl=vector; using vpil=vector>; using vpli=vector>; using vpd=vector; using vb=vector; template using pq=priority_queue,greater>; template using rpq=priority_queue>; template using Tree=tree,rb_tree_tag,tree_order_statistics_node_update>; #define ovl4(a,b,c,d,name,...) name #define rep(...) ovl4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__) #define rep1(a) for(int i=0; i=0; i--) #define rrep2(i,a) for(int i=a; i>=0; i--) #define rrep3(i,a,b) for(int i=a; i>=b; i--) #define rrep4(i,a,b,c) for(int i=a; i>=b; i-=c) #define atrep(i,v) for(auto i:v) void in(){} templatevoid in(T&... a){(cin >>... >>a);} template void vin(vector &v,int n=-1,int s=0){if(n==-1)n=v.size();rep(i,s,s+n)in(v[i]);} #define INT(...) int __VA_ARGS__;in(__VA_ARGS__) #define LL(...) ll __VA_ARGS__;in(__VA_ARGS__) #define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__) #define DBL(...) double __VA_ARGS__;in(__VA_ARGS__) #define LD(...) ld __VA_ARGS__;in(__VA_ARGS__) #define STR(...) string __VA_ARGS__;in(__VA_ARGS__) #define CHR(...) char __VA_ARGS__;in(__VA_ARGS__) void VIN(){} template void VIN(int ind,vector& v,Ts&... vs){vin(v,v.size()-ind,ind);if constexpr(sizeof...(vs)>0)VIN(ind,vs...);} template void setin(vector &a,vector &b,int ind=0,int n=-1){if(n==-1)n=a.size();rep(i,ind,n)in(a[i],b[i]);} template bool chmax(T &a,Ts... b){T c=a;for(auto i:{b...})a=max(a,i);return a==c;} template bool chmin(T &a,Ts... b){T c=a;for(auto i:{b...})a=min(a,i);return a==c;} void print(){cout<<"\n";} template void print(const T &a,const Ts&... b){cout < void vprint(vector &v,bool ind1=false,string aid=" "){rep(i,(int)ind1,v.size()){if(i>(int)ind1){cout < bool eql(const T &a){return true;}; template bool eql(const T& a,const Ts&... b){bool ret=true;for(auto i:{b...})ret&=(i==a);return ret;} bool operator==(const string& a,const string& b){return a.compare(b)==0;} random_device rd; mt19937 mt(rd()); const int INF=1e9; const ll LINF=1e18; const ll MOD=1e9+7; const ll MMOD=998244353; const ld eps=1e-10; bool deql(const ld &a){return true;} template bool deql(const ld& a,const Args&... b){bool ret=true;for(auto i:{b...})ret&=(inr(-eps,i-a,eps));return ret;} int dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1}; class prime{ private: vl a1={2,7,61}; vl a2={2,325,9375,28178,450775,9780504,1795265022}; __int128_t modpow(__int128_t a,__int128_t b,__int128_t mod=MOD){ __int128_t ret=1; a%=mod; while(b>0){if(b&1)ret=(ret*a)%mod;a=(a*a)%mod;b>>=1;} return ret; } bool is_prime(ll n,vl& A){ ll s=0,d=n-1; while(!(d&1)){++s;d>>=1;} for(auto a:A){ if(n<=a)return true; ll t,y=modpow(a,d,n); if(y!=1){ for(t=0;tll{return ((__int128_t)x*x+s)%n;}; while(d==1){ x=f(x),y=f(f(y)); d=gcd(abs(x-y),n); } if(d!=1 && d!=n)return d; } } void factor_dfs(int idx,ll val,vl &ret,vpli &fac){ int size=fac.size(); if(idx==size){ret.push_back(val);return;} ll v=fac[idx].ft; int c=fac[idx].sd; ll m=1; for(int i=0; i<=c; i++){ factor_dfs(idx+1,val*m,ret,fac); m*=v; } return; } public: bool isprime(ll n){ if(n<=1)return false; if(n==2)return true; if(n&1==0)return false; if(n<4759123141LL)return is_prime(n,a1); else return is_prime(n,a2); } map factorize(ll n){ map ret; if(n==1)return ret; if(isprime(n)){ ret[n]=1; return ret; } ll fac=findfactor(n); ret=factorize(fac); map ret_=factorize(n/fac); if(ret.size()>ret_.size()){for(auto i:ret_){ret[i.ft]+=i.sd;}return ret;} else{for(auto i:ret){ret_[i.ft]+=i.sd;}return ret_;} } vl enumerate(ll n){ map f=factorize(n); vpli fac; for(auto i:f)fac.push_back(i); vl ret; factor_dfs(0,1,ret,fac); return ret; } }; int main(){ ios::sync_with_stdio(false);std::cin.tie(nullptr); INT(x); prime p; auto d=[](prime p,int n){return p.enumerate(n).size();}; auto f=[d](prime p,int n)->int{return n-d(p,n);}; vector> ans; rep(a,1,x){ int b=x-a; int k=abs(f(p,a)-f(p,b)); pair pa={k,{a,b}}; ans.push_back(pa); } Sort(ans); int val=ans[0].ft; atrep(i,ans){ if(i.ft!=val)break; print(i.sd.ft,i.sd.sd); } return 0; }