/*
ID: your_id_here
PROG: preface
LANG: C++
*/
#include <iostream>
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int f[15]={1,4,5,9,10,40,50,90,100,400,500,900,1000},num[10];
int co[15][10]={{1},{1,1},{0,1},{1,0,1},{0,0,1},{0,0,1,1},{0,0,0,1},{0,0,1,0,1},{0,0,0,0,1},{0,0,0,0,1,1},{0,0,0,0,0,1},{0,0,0,0,1,0,1},{0,0,0,0,0,0,1}};
void pre(int x)
{
int i,j;
for(i = 12 ; i >=0 ; i--)
{
if(x>=f[i])
{
while(x>=f[i])
{
x-=f[i];
for(j = 0; j < 7 ; j++)
{
num[j]+=co[i][j];
}
}
}
}
}
int main()
{
freopen("preface.in","r",stdin);
freopen("preface.out","w",stdout);
int n,i,j;
char ss[10] = {'I','V','X','L','C','D','M'};
cin>>n;
for(i = 1; i <= n ; i++)
{
pre(i);
}
for(i = 0 ; i < 7 ; i++)
{
if(num[i]!=0)
{
cout<<ss[i]<<" "<<num[i]<<endl;
}
}
fclose(stdin);
fclose(stdout);
return 0;
}