#include<bits/stdc++.h>
using namespace std;
void cpy(int a[],int b[], int offset){
for(int i = 1;i <= a[0];i++)
b[i+offset] = a[i];
b[0] = offset+a[0];
}
bool cmp(int a[], int b[]){
for(int i = 1;i <= a[0];i++){
if(a[i] > b[i]) return true;
if(a[i] < b[i]) return false;
}
return true;
}
void sub(int a[], int t[]){
for(int i = 1;i <= a[0];i++){
if(a[i] < t[i]){
a[i-1]--;
a[i] += 10;
}
a[i] -= t[i];
}
}
int main() {
string s1, s2;
cin >> s1 >> s2;
int a[5050] = {0}, b[5050] = {0}, c[5050] = {0};
a[0] = s1.size(), b[0] = s2.size();
for(int i = 1;i <= a[0];i++)
a[i] = s1[i-1]-'0';
for(int i = 1;i <= b[0];i++)
b[i] = s2[i-1]-'0';
c[0] = a[0] - b[0] + 1;
int t[11000] = {0};
for(int i = 1;i <= c[0];i++){
memset(t, 0, sizeof(t));
cpy(b, t, i-1);
a[0] = t[0];
while(cmp(a, t)){
sub(a, t);
c[i]++;
}
}
bool flag = false;
for(int i = 1;i <= c[0];i++){
if(c[i] != 0 && !flag){ cout << c[i];flag = true; }
else if(flag) cout << c[i];
}
if(!flag) cout << 0;
cout << endl;
flag = false;
for(int i = 1;i <= a[0];i++){
if(a[i] != 0 && !flag){ cout << a[i];flag = true; }
else if(flag) cout << a[i];
}
if(!flag) cout << 0;
return 0;
}