#include <iostream>
using namespace std;
int main()
{
int v[30],n,i,x,y;
cin>>n;
for(i=0;i<n;i++)
cin>>v[i];
for(i=0;i<n;i++)
{
int S1=0,S2=0;
x=v[i];
y=v[i+1];
while(x!=0 || y!=0)
{
S1=S1+x%10;
S2=S2+y%10;
x=x/10;
y=y/10;
}
if(S1==S2)
cout<<v[i]<<' '<<v[i+1]<<endl;
}
return 0;
}