//lg p5410
//Copyright yeyou26
#include<bits/stdc++.h>
using namespace std;

const int N = (2e7)+10;

char a[N],b[N];
int p[N],z[N];
int lena,lenb;

long long wz,wp;

void init();
void get_z();
void get_p();
void calculate();
void print();
void debug();

int main()
{
    freopen("working.in","r",stdin);
    freopen("working.out","w",stdout);
    init();
    get_z();
    get_p();
    calculate();
    print();
    // debug();
    return 0;
}

//Function Implementation

void debug()
{
    cout<<endl;
    for(int i=1;i<=lenb;i++) cout<<z[i]<<" ";
    cout<<endl;
    for(int i=1;i<=lena;i++) cout<<p[i]<<" ";
    cout<<endl;
}

void print()
{
    cout<<wz<<endl<<wp;
}

void calculate()
{
    for(int i=1;i<=lenb;i++)
    {
        wz^=(long long)i*(z[i]+1);
    }
    for(int i=1;i<=lena;i++)
    {
        wp^=(long long)i*(p[i]+1);
    }
}

void init()
{
    cin>>(a+1)>>(b+1);
    lena=strlen(a+1);
    lenb=strlen(b+1);
}

void get_z()
{
    z[1]=lenb;
    for(int i=2,l=0,r=0;i<=lenb;i++)
    {
        if(i<=r) z[i]=min(z[i-l+1],r-i+1);
        while(b[1+z[i]]==b[i+z[i]]) z[i]++;
        if(i+z[i]-1>r) l=i,r=i+z[i]-1;   
    }
}

void get_p()
{
    for(int i=1,l=0,r=0;i<=lena;i++)
    {
        if(i<=r) p[i]=min(z[i-l+1],r-i+1);
        while(i+p[i]<=lena && 1+p[i]<=lenb && a[i+p[i]]==b[1+p[i]]) p[i]++;
        if(i+p[i]-1>r) l=i,r=i+p[i]-1; 
    }
}