https://vjudge.net/problem/UVA-10013
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cctype>
#include<cstring>
using namespace std;
const int N=1e6+10;
int a[N];
int main(){
int n;
scanf("%d",&n);
int m,z=1;
while(n--){
if(z==1)z++;
else puts("");
memset(a,0,sizeof(a));
int b;
cin>>m;
for(int i=m-1;i>=0;i--){
scanf("%d",&a[i]);
scanf("%d",&b);
a[i]+=b;
}
int k=0;
while(a[k]){
a[k+1]+=a[k]/10;
a[k]%=10;
k++;
}
for(int i=k-1;i>=0;i--)
printf("%d",a[i]);
printf("\n");
}
}