#include <stdio.h>
#include <stdlib.h>
typedef struct Polynode* Ptr;
struct Polynode{
int Coef;
int Expon;
Ptr Next;
};
typedef Ptr Poly;
void Get(Poly P){
Poly t,rear;
int coef,expon;
rear=P;
while(scanf("%d %d",&coef,&expon)!=EOF){
t=(Poly)malloc(sizeof(struct Polynode));
coef*=expon;
if(expon!=0) --expon;
if(coef==0) expon=0;
t->Coef=coef;
t->Expon=expon;
t->Next=NULL;
rear->Next=t;
rear=t;
}
}
void Print(Poly P){
Poly t=P->Next;
if(t->Next==NULL)
printf("%d %d",t->Coef,t->Expon);
else{
while(t){
if(t->Next&&t->Next->Coef)
{
if(t->Coef) printf("%d %d",t->Coef,t->Expon);
}
else{
if(t->Coef) printf("%d %d",t->Coef,t->Expon);
}
t=t->Next;
}
}
}
int main(){
Poly P;
P=(Poly)malloc(sizeof(struct Polynode));
P->Next=NULL;
Get(P);
Print(P);
return 0;
}