local mfl, mce = math.floor, math.ceil local msq = math.sqrt local mab = math.abs local function getprimes(x) local primes = {} local allnums = {} for i = 1, x do allnums[i] = true end for i = 2, x do if allnums[i] then table.insert(primes, i) local lim = mfl(x / i) for j = 2, lim do allnums[j * i] = false end end end return primes end local function solve(x, primes) local ret = 1 local prime_num = #primes local lim = mce(msq(x)) local primepos = 1 local dv = primes[primepos] while primepos <= prime_num and dv <= lim do if x % dv == 0 then local cnt = 1 x = x / dv while x % dv == 0 do x = x / dv cnt = cnt + 1 end lim = mce(msq(x)) ret = ret * (cnt + 1) end if primepos == prime_num then break end primepos = primepos + 1 dv = primes[primepos] end if x ~= 1 then ret = ret * 2 end return ret end local x = io.read("*n") local primes = getprimes(mce(msq(2000000))) local t = {} for i = 1, x - 1 do t[i] = i - solve(i, primes) end local minval, mins = mab(t[1] - t[x - 1]), {1} for i = 2, x - 1 do local v = mab(t[i] - t[x - i]) if v < minval then minval, mins = v, {i} elseif v == minval then table.insert(mins, i) end end for i = 1, #mins do print(mins[i] .. " " .. x - mins[i]) end