1. 


/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem: Twin Primes (10394)
* @author Christian Mitterreiter
* @author Rolf Luigs
* @version 1.0, 03/23/2009
* Status : Accepted
* Runtime: 1.850
*/

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

int n = 19000000;
int quadrat = 0;

boolean[]Sieb = new boolean[n];

for(int i=0; i<n ; i++)
Sieb[i]=true;
Sieb[0]=false;
Sieb[1]=false;

for(int i = 1; i<n ; i++) {
quadrat = quadrat + 2*i - 1; // (i+1)=i+2*(i+1)-1
if (quadrat>n) break; // Schleifenabbruch wenn i>n
if (Sieb[i])

for(int j=2*i;j<n;j+=i)
Sieb[j]=false; // nun stehen nur noch Primzahlen in der Liste
}

long[]primes = new long[n/5]; //Array mit Primzahlen
int index = 0;
for(int j =0;j<Sieb.length;j++) {
if(Sieb[j] ==(true)) {
primes[index] = j;
index++;
}
}

long[]twinprimes = new long[n/10]; //Array mit allen Primzahlzwillingen
int zaehler = 0;
for(int z = 0; z<twinprimes.length-1;z++) {
if(primes[z] +2 == primes[z+1]) {
twinprimes[zaehler] = primes[z];
twinprimes[zaehler+1] = primes[z+1];
zaehler = zaehler +2;
}
}


Scanner sc = new Scanner(System.in);
int input;

while(sc.hasNextInt()) {
input = sc.nextInt();

System.out.print("(" + twinprimes[2*(input-1)]+", "+ twinprimes[(2*(input-1))+1] + ")");

if(sc.hasNextInt()) System.out.println();
else System.out.print("\n");
}
}
}