import java.util.Scanner;
public class Class2018020101 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[] a = new int[101]; //初始化数组,数组各项都为0
int x,count = 0;//用临时变量X存放读入的指数 ,count用来计数两次循环
do{
x = in.nextInt(); //读入指数
a[x] = a[x] +in.nextInt();//读入幂的系数,如果同幂的系数则相加
if(x == 0) count++;
}while(count != 2);//count等于2的时候表明读入了两个多项式,跳出循环
for(int i = a.length-1; i >1; i--){//循环输入各项
if(a[i]!=0){ //指数为0的不输出
System.out.print(a[i]+"x"+i+"+");
}
}
if(a[1]!=0){//增加a[1]项的系数判断
System.out.print(a[1]+"x"+"+");//输出a[1]项
}
System.out.println(a[0]); //输出a[0]项
in.close();
}
}