#include<stdio.h>
#include<iostream>
#include<string.h>
#include<queue>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<fstream>
#include<math.h>
#include<iomanip>
#include<time.h>
#include<assert.h>
#include<stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define db double
#define inf 1000000007
#define mod 1000000007
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define N 100005
#define pi 3.14159265358979323846
#define DBG(vari) cerr<<#vari<<"="<<(vari)<<endl;
#define FOREACH(i,t) for(__typeof(t.begin()) i=t.begin();i!=t.end();i++)
char s[1005][1005];
stack<int>q;
void cal(int u)
{
if(u==1)printf("</ol>\n");
else if(u==2)printf("</ul>\n");
else printf("</li>\n");
}
void parse(int l,int r,int i)
{
if(l>r)
{
int u;
while(!q.empty())u=q.top(),cal(u),q.pop();
return;
}
if(s[l][i]!='#'&&s[l][i]!='*')
{
if(!q.empty())printf("<li>\n%s\n</li>\n",s[l]+i);
else printf("%s\n",s[l]);
parse(l+1,r,i);return;
}
int m=l;
while(m<=r&&s[m][i]==s[l][i])m++;
if(m-l==1)
{
if(!q.empty())printf("<li>\n%s\n</li>\n",s[l]+i);
else printf("%s\n",s[l]);
parse(l+1,r,i);return;
}
if(!q.empty())q.push(3),printf("<li>\n");
if(s[l][i]=='#')q.push(1),printf("<ol>\n");
else q.push(2),printf("<ul>\n");
parse(l,m-1,i+1);
parse(m,r,i);
}
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int T,i,j,ca=0,m,k,n=0;
while(~scanf("%s",s[n]))n++;
parse(0,n-1,0);
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHN0cmluZy5oPgojaW5jbHVkZTxxdWV1ZT4KI2luY2x1ZGU8YWxnb3JpdGhtPgojaW5jbHVkZTxzdHJpbmc+CiNpbmNsdWRlPG1hcD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