//prob B - poly-polygonal

#include <iostream>

using namespace std;

int main()
{
  int n, i;
  long int P[50], M[50],K[50],A[50],Num[50], s, min;
 

  cin>>n;
  while(n>0)
  {
	  for(i=0;i<n;i++)
		  cin>>P[i];
	  cin>>s;

	  for(i=0;i<n;i++)
	  {
	    M[i]=P[i]-2;
		A[i]=P[i]-3;
		K[i]=2;
		Num[i]=1;
	  }
	  // we keep track of next k-poly num for each k
	  //get 1st k-poly num for each
	  for(i=0;i<n;i++)
	  {
 		while(Num[i]<s)
		  {
			  Num[i] += M[i]*K[i]-A[i];
			  K[i] += 1;
		  }
	  }
	  //now keep updating the k-polys until you find a
	  //poly-polygonal number
	  int count = 0;
	  while(count<5)
	  {
		  //find min
		  min = Num[0];
		  for(i=0;i<n;i++)
			  if(Num[i]<min)
				  min=Num[i];
		  int countmins=0;
		  for(i=0;i<n;i++)
			  if(Num[i]==min)
				  countmins++;
		  if(countmins>1)    //found a poly-poly
		  {
			  count++;
			  cout<<min;
              
			  bool first = true;	//this is for print control
			  for(i=0;i<n;i++)
				  if(Num[i]==min) {
                 if (first)
                 	cout << ":";
                 else
                 	cout <<' ';
					  cout<<P[i];
                 first = false;
              }
			  cout<<endl;
		  }
		  //update those with mins
		  for(i=0;i<n;i++)
			  if(Num[i]==min)
			  {
				  Num[i] += M[i]*K[i]-A[i];
				  K[i] += 1;
			  }
	  }

	 cin>>n;
     if (n != 0)
		  cout<<endl;

  }
  return 0;
}

