/*
TASK:trains
LANG:C++
*/
# include <iostream>
using namespace std;
int main ()
{
    int n,m,p,c,f,br=0;
    cin>>n>>m;
    for (int i=0;i<n;i++)
    {
        cin>>p>>c>>f;
        if (p==0)
           cout<<"################################"<<endl;
        else
        { 
            for (int j=0;j<p-1;j++)
            {
                cout<<"#";
                br++;
            }
                if (c!=0 || f!=0)
                   {
                         cout<<"(H H]";
                         br=br+5;
                   }
                for (int z=0;z<c;z++)
                    {
                         cout<<"[XXX]";
                         br=br+5;
                    }
                for (int h=0;h<f;h++)
                    {
                         cout<<"(O O)";
                         br=br+5;
                    }
                for (int x=br;x<m;x++)
                    {
                         cout<<"#";
                    }
            }
                cout<<endl;                  
    }
}
