//不知道为什么,我的代码怎么这么多
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
char a[25], b[25], s[25];
int aa[25], bb[25], num[25];
int la, lb, flag = -1;
int getnum(char c)
{
if (c >= '0' && c <= '9')
return c - '0';
else
return c - 'A' + 10;
}
char getchar(int c)
{
if (c >= 0 && c <= 9)
return c + '0';
else
return c - 10 + 'A';
}
void make()
{
memset(aa, 0, sizeof(aa));
memset(bb, 0, sizeof(bb));
memset(num, 0, sizeof(num));
la = strlen(a); lb = strlen(b);
for (int i = la - 1, j = 0; i > 0; i--)
aa[j++] = getnum(a[i]);
for (int i = lb - 1, j = 0; i > 0; i--)
bb[j++] = getnum(b[i]);
}
void compare()
{
if (la < lb) flag = 0;
else if (la > lb) flag = 1;
else
{
for (int i = la - 2; i >= 0; i--)
if (aa[i] < bb[i])
{
flag = 0; break;
}
else if (aa[i] > bb[i])
{
flag = 1; break;
}
}
}
void print()
{
bool start = false;
for (int i = 23; i >= 0; i--)
{
if (num[i] != 0)
start = true;
if (start)
printf("%c", getchar(num[i]));
}
printf("\n");
}
void solve()
{
flag = -1;
if (a[0] == '-' && b[0] == '+')
{
printf("%s %s\n", a, b);
compare();
if (flag == -1)
printf("+0\n");
else if (flag == 0)
{
printf("+");
for (int i = 0; i < lb - 1; i++)
{
if (bb[i] >= aa[i])
num[i] = bb[i] - aa[i];
else if (bb[i] < aa[i])
{
bb[i] += 16; bb[i + 1]--;
for (int j = i + 1; j + 1 < lb - 1; j++)
{
if (bb[j] < 0)
bb[j] += 16, bb[j + 1]--;
else break;
}
num[i] = bb[i] - aa[i];
}
}
print();
}
else
{
printf("-");
for (int i = 0; i < la - 1; i++)
{
if (aa[i] >= bb[i])
num[i] = aa[i] - bb[i];
else if (aa[i] < bb[i])
{
aa[i] += 16; aa[i + 1]--;
for (int j = i + 1; j < la - 1; j++)
if (aa[j] < 0)
aa[j] += 16, aa[j + 1]--;
else break;
num[i] = aa[i] - bb[i];
}
}
print();
}
}
else if (a[0] == '+' && b[0] == '-')
{
printf("%s %s\n", b, a);
compare();
if (flag == -1)
printf("+0\n");
else if (flag == 0)
{
printf("-");
for (int i = 0; i < lb - 1; i++)
{
if (bb[i] >= aa[i])
num[i] = bb[i] - aa[i];
else if (bb[i] < aa[i])
{
bb[i] += 16; bb[i + 1]--;
for (int j = i + 1; j < lb - 1; j++)
if (bb[j] < 0)
bb[j] += 16, bb[j + 1]--;
else break;
num[i] = bb[i] - aa[i];
}
}
print();
}
else
{
printf("+");
for (int i = 0; i < la - 1; i++)
{
if (aa[i] >= bb[i])
num[i] = aa[i] - bb[i];
else if (aa[i] < bb[i])
{
aa[i] += 16; aa[i + 1]--;
for (int j = i + 1; j < la - 1; j++)
if (aa[j] < 0)
aa[j] += 16, aa[j + 1]--;
else break;
num[i] = aa[i] - bb[i];
}
}
print();
}
}
else
{
compare();
if (a[0] == '+')
{
if (flag == 0 || flag == -1)
printf("%s %s\n", a, b);
else
printf("%s %s\n", b, a);
printf("+");
}
else
{
if (flag == 0 || flag == -1)
printf("%s %s\n", b, a);
else
printf("%s %s\n", a, b);
printf("-");
}
for (int i = 0; i < 23; i++)
{
num[i] += aa[i] + bb[i];
if (num[i] >= 16)
num[i] -= 16, num[i + 1]++;
}
print();
}
}
int main()
{
while (scanf("%s%s", a, b) != EOF)
{
if (a[1] == '0' && b[1] == '0')
break;
make();
solve();
getchar();
}
return 0;
}