#include <iostream>
using namespace std;
int main()
{
int i, j, k, nArray[10] = {0}, l = 0;
cin >> k;
while (0 != k)
{
nArray[l++] = k;
cin >> k;
}
k = 0;
while ( k < l)
{
cout << "#case " << nArray[k] << ":" << endl;
for (i = 1; i <= nArray[k]; i++)
{
for (j = 1; j <= nArray[k]; j++)
{
cout << i << "*" << j << "=" << i*j << " ";
}
cout << endl;
}
k++;
}
return 0;
}