#B2132. Prime Pairs

    ID: 11214 Type: Default 1000ms 256MiB

Prime Pairs

Prime Pairs

We define two primes that differ by \(2\) as a prime pair. For example, \(5\) and \(7\), \(17\) and \(19\) are prime pairs. Given an integer \(n\), your task is to find all prime pairs such that both primes are less than or equal to \(n\).

If no such pairs exist, output 0.

inputFormat

The input consists of a single integer \(n\) \((1 \leq n \leq 10^6)\).

outputFormat

For each prime pair \((p, q)\) satisfying \(q-p=2\) and \(p, q \leq n\), output a line containing the two numbers separated by a space, in ascending order of \(p\). If there are no prime pairs, output 0.

sample

10
3 5

5 7

</p>