// CPP program to sum two numbers represented two
// arrays.
#include <bits/stdc++.h>
using namespace std;
// Return sum of two number represented by the arrays.
// Size of a[] is greater than b[]. It is made sure
// be the wrapper function
void calSumUtil(int a[], int b[], int n, int m)
{
// array to store sum.
int sum[n];
int i = n - 1, j = m - 1, k = n - 1;
int carry = 0, s = 0;
// Until we reach beginning of array.
// we are comparing only for second array
// because we have already compare the size
// of array in wrapper function.
while (j >= 0) {
// find sum of corresponding element
// of both arrays.
s = a[i] + b[j] + carry;
sum[k] = (s % 10);
// Finding carry for next sum.
carry = s / 10;
k--;
i--;
j--;
}
// If second array size is less the first
// array size.
while (i >= 0) {
// Add carry to first array elements.
s = a[i] + carry;
sum[k] = (s % 10);
carry = s / 10;
i--;
k--;
}
// If there is carry on adding 0 index elements.
// append 1 to total sum.
if(carry!=0)
sum[0]=carry;
for(i=0;i<n;i++)
cout<<sum[i]<<", ";
}
// Wrapper Function
void calSum(int a[], int b[], int n, int m)
{
// Making first array which have
// greater number of element
if (n >= m)
calSumUtil(a, b, n, m);
else
calSumUtil(b, a, m, n);
}
// Driven Program
int main()
{
int n,m;
cin>>n>>m;
int a[n],b[m];
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<m;i++)
cin>>b[i];
calSum(a,b,n,m);
cout<<“END”;
return 0;
}