import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

public class Main {
	
	public static int fact(int n)
	{
		if(n == 1)
		{
			return 1;
		}
		else
		{
			return fact(n-1)*n;
		}
	}
	
	public static int fibbonaci(int n)
	{
		if(n == 1 || n == 2)
		{
			return 1;
		}
		else
		{
			return fibbonaci(n-1) + fibbonaci(n-2);
		}
	}
	
	public static int findFirstDiviseur(int n)
	{
		for(int i = 2 ; i < Math.sqrt(n) ; i++)
		{
			if(n%i == 0)
				return i;
		}
		return 0;
	}
	
	static BufferedImage img = new BufferedImage(1000, 500, BufferedImage.TYPE_INT_RGB);
	
	public static void main(String[] args)
	{
		boolean[] premiers = new boolean[1000000000];
		
		int i = 2;
		while(i < (premiers.length-1)/2)
		{
			if(!premiers[i])
			{
				for (int j = 2*i; j < premiers.length; j+=i)
				{
					premiers[j] = true;
				}
			}
			do
			{
				i++;
			}while(premiers[i] && i < premiers.length-1);
		}
		
		int memoire = 0;
		int count = 0, maxcount = 0;
		
		float min = 500;
				int x = 0;
		int etude = 100;
		
		
		
		for (int j = 0 ; j < premiers.length/etude  ; j++) {
			//float average = 0;
			for(i = j*etude ; i < (j+1)*etude ; i++)
			{
				if(!premiers[i])
				{
					if(count > maxcount)
					{
						System.out.println(count);
						maxcount = count;
						memoire = i - count;
					}
					count = 0;
					//average++;
				}
				else
				{
					count++;
				}
			}
//			average/=etude;
//			average *= 100;
//
//			if(average == 0)
//			System.out.println(j*etude + " --> " + (j+1)*etude + " : " + average + "%");
//			img.setRGB((int) (j*etude*1000/premiers.length), (int) (499-average*2), 255 << 8);
//			if(average < min)
//			{
//				min = average;
//				x = (j*etude*1000/premiers.length);
//			}
		}
		// 1671800
		for (int j = memoire ; j < memoire + maxcount; j++) {
			int diviseur = findFirstDiviseur(j);
			if(diviseur > 1000)
			System.out.println(j + " --> OMFG : "+ diviseur + "*" + j/diviseur);
		}
		
		
		System.out.println(maxcount + " " + memoire);
		
//		for (int j = 0; j < 1000; j++) {
//			img.setRGB(j, (int)(499-min*10), 255 << 16);
//		}
//		for (int j = 0; j < 500	; j++) {
//			img.setRGB(x, j, 255 << 16);
//		}
//		try {
//			ImageIO.write(img, "png", new File("image.png"));
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
	}
}
