#include <iostream>
using namespace std;
string t[3];
int t_count=0;
int t_max=2;
void go()
{
cout<<"<table>"<<"<tr>";
for(int x=0; x<=t_max; x++)if(t[x]!="OOO")cout<<"<td>"<<t[x]<<"</td>";
cout<<"</tr>"<<"</table>"<<endl;
for(int x=0; x<=t_max; x++)t[x]="OOO";
t_count=0;
}
int main ()
{
string a;
int i=0;
for(int x=0; x<=t_max; x++)t[x]="OOO";
while(true)
{
getline(cin, a);
if(cin.fail())return 0;
if(a[1]=='*')
{
if(t_count>t_max) go();
string b(a, a.find('|')+1, a.find(']')-a.find('|')-1);
string save=string(a, 2, a.size()-2)+'\n'+"[["+b+"|90px|thumb|left]]"+'\n'+"{{clear}}"+'\n';;
t[t_count]=save;
t_count++;
}
else if(a[0]=='*')
{
if(t_count!=0)go();
if(i%5==0){cout<<"=="<<i/5<<"=="<<endl<<"==="<<string(a, 1, a.size()-1)<<"==="<<endl;}
else cout<<"==="<<string(a, 1, a.size()-1)<<"==="<<endl;
i++;
}
else cout<<a<<endl;
}
}