#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int n, p, l, v[1005][1005];
char voc[]="aeiou";
l=strlen(voc);
cin >> n >> p;
int x=52;
for(int i=1;i<n;i++)
{
x=x*50;
x=x%123457;
}
cout << x << " ";
v[0][0]=26;
v[1][0]=26;
for(int i=1;i<n;i++)
{
v[0][i]=(v[1][i-1]*26)%123457;
v[1][i]=(v[0][i-1] + v[1][i-1]*26)%123457;
}
cout << v[0][n-1]+v[1][n-1] << " ";
v[0][0]=21;
v[1][0]=5;
int ok=1;
for(int i=1;i<n;i++)
{
v[0][i]=(v[0][i-1]*21)%123457;
if(ok<p)
{
v[1][i]=(v[1][i-1]*26)%123457;
ok++;
}
else v[1][i]=(v[1][i-1]*21)%123457;
}
if(p==0)cout << v[0][n-1];
else cout << v[0][n-1] + v[1][n-1]*n;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG1haW4oKQp7CiAgICBpbnQgbiwgcCwgbCwgdlsxMDA1XVsxMDA1XTsKICAgIGNoYXIgdm9jW109ImFlaW91IjsKICAgIGw9c3RybGVuKHZvYyk7CiAgICBjaW4gPj4gbiA+PiBwOwogICAgCiAgICBpbnQgeD01MjsKICAgIGZvcihpbnQgaT0xO2k8bjtpKyspCiAgICB7CiAgICAgICAgeD14KjUwOwogICAgICAgIHg9eCUxMjM0NTc7CiAgICB9CiAgICBjb3V0IDw8IHggPDwgIiAiOwogICAgCiAgICB2WzBdWzBdPTI2OwogICAgdlsxXVswXT0yNjsKICAgIGZvcihpbnQgaT0xO2k8bjtpKyspCiAgICB7CiAgICAgICAgdlswXVtpXT0odlsxXVtpLTFdKjI2KSUxMjM0NTc7CiAgICAgICAgdlsxXVtpXT0odlswXVtpLTFdICsgdlsxXVtpLTFdKjI2KSUxMjM0NTc7CiAgICB9CiAgICAKICAgIGNvdXQgPDwgdlswXVtuLTFdK3ZbMV1bbi0xXSA8PCAiICI7CiAgICAKICAgIHZbMF1bMF09MjE7CiAgICB2WzFdWzBdPTU7CiAgICBpbnQgb2s9MTsKICAgIGZvcihpbnQgaT0xO2k8bjtpKyspCiAgICB7CiAgICAgICAgdlswXVtpXT0odlswXVtpLTFdKjIxKSUxMjM0NTc7CiAgICAgICAgaWYob2s8cCkKICAgICAgICB7CiAgICAgICAgCXZbMV1baV09KHZbMV1baS0xXSoyNiklMTIzNDU3OwogICAgICAgIAlvaysrOwogICAgICAgIH0KICAgICAgICBlbHNlIHZbMV1baV09KHZbMV1baS0xXSoyMSklMTIzNDU3OwogICAgfQogICAgCiAgICBpZihwPT0wKWNvdXQgPDwgdlswXVtuLTFdOwogICAgZWxzZSBjb3V0IDw8IHZbMF1bbi0xXSArIHZbMV1bbi0xXSpuOwp9