1. JAVA, Peter Schnitzler

/* Problem : 10419
* Author : Peter Schnitzler
* Status : AC
* Runtime : 1.98
*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;



public class Main {

static byte primeUse[];


private static boolean [] getPrimes()
{
boolean [] result = new boolean [300];
for (int count = 2; count < 300; count++)
{
result[count] = true;
}
result[0] = false;
result[1] = false;

for (int count = 2; count < 300; count++)
{
if (result[count])
{
for (int count2 = count*2; count2 < 300; count2+=count )
{
result[count2] = false;
}
}
}

return result;
}


private static short[] getLexPrimes(boolean primes [])
{
int cage = 0;

for (short count = 0; count < 300; count++)
{
if (primes[count]) cage++;
}

short result [] = new short[cage];
cage = 0;

for (short count = 0; count < 300; count++)
{
if (primes[count])
{
result[cage] = count;
cage++;
}
}

sort(result, 0 , cage - 1);

return result;
}


private static void sort(short array[], int min, int max)
{
if (max != min)
{
String pivot = "" + array[min];

int divide = min;

for (int count = min + 1; count <= max; count++)
{
if (pivot.compareTo("" + array[count]) >= 0)
{
divide++;
short temp = array[divide];
array[divide] = array[count];
array[count] = temp;
}
}

short temp = array[min];
array[min] = array[divide];
array[divide] = temp;

if ((divide - min) >= (max - divide))
{
sort(array, min , divide - 1);
sort(array, divide, max);
}
else
{
sort(array, min, divide);
sort(array, divide + 1, max);
}
}
}


private static void setPrimeUse(boolean bArray[])
{
primeUse = new byte[bArray.length];

for (int count = 0; count < bArray.length; count ++)
{
if(bArray[count])
{
primeUse[count] = 0;
}
else
{
primeUse[count] = Byte.MAX_VALUE;
}
}

primeUse[2] = 1;
}


public static void main(String[] args) throws IOException
{
boolean bPrimes[] = getPrimes();

short primes [] = getLexPrimes(bPrimes);

setPrimeUse(bPrimes);


BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer tok = new StringTokenizer(reader.readLine());

int i1 = Integer.parseInt(tok.nextToken());
int i2 = Integer.parseInt(tok.nextToken());
int count = 1;

while (i1 != 0 && i2 != 0)
{


String resu;
if (i2 > 1)
{
resu = findCom(i1, primes, i2, 0);
}
else
{
if (i1 < 300 && bPrimes[i1])
{
resu = "" + i1;
}
else
{
resu = null;
}
}

if (resu != null)
{
System.out.println("CASE " + count + ":\n" + resu);
}
else
{
System.out.println("CASE " + count + ":\nNo Solution.");
}

count++;
tok = new StringTokenizer(reader.readLine());
i1 = Integer.parseInt(tok.nextToken());
i2 = Integer.parseInt(tok.nextToken());
}
}




private static String findCom(int total, short primes[], int cop, int min)
{
if (cop == 2)
{
for(int count = min; count < primes.length; count++)
{
if (primeUse[primes[count]] < 2)
{
primeUse[primes[count]]++;

int rest = total -primes[count];
if ((rest > 1) && (rest < primeUse.length) && (primeUse[rest] < 2))
{
primeUse[primes[count]]--;


return primes[count] + "+" + rest;
}

primeUse[primes[count]]--;
}
}

return null;
}
else
{
for(int count = min; count < primes.length; count ++)
{
if (primeUse[primes[count]] < 2)
{
int rest = total - primes[count];

if (rest >= 5)
{
primeUse[primes[count]]++;

String resp = findCom(rest, primes, cop - 1, count);

primeUse[primes[count]]--;

if (resp != null)
{
return primes[count] + "+" + resp;
}
}
}
}
return null;
}
}

}