Two testcases are failed in this code and I can't understand what's wrong in this code

#include
using namespace std;
int main()
{
int N, M;
int a[1000], b[1000];

cin >> N;
for(int i=0; i<N; i++)
{
	cin >> a[i];
}

cin >> M;
for(int i=0; i<M; i++)
{
	cin >> b[i];
}
int x=abs(M-N);

if(M>N)
{
	for(int i=M-1; i>=x; i--)
	{
		b[i]+=a[i-x];
		if(b[i]>9)
		{
			b[i-1]+=1;
			b[i]=b[i]-10;
		}
	}
	for(int i=0; i<M; i++)
	{
		cout << b[i] << ", ";
	}
	cout << "END";
}

else if(N>M)
{
	for(int i=N-1; i>=x; i--)
	{
		a[i]+=b[i-x];
		if(a[i]>9)
		{
			a[i-1]+=1;
			a[i]=a[i]-10;
		}
	}
	for(int i=0; i<N; i++)
	{
		cout << a[i] << ", ";
	}
	cout << "END";
}

else
{
	for(int i=M-1; i>=x; i--)
	{
		a[i]+=b[i-x];
		if(a[i]>9)
		{
			a[i-1]+=1;
			a[i]=a[i]-10;
		}
	}

	for(int i=0; i<N; i++)
	{
		cout << a[i] << ", ";
	}

	cout << "END";
}

return 0;

}

hello @ayush.18
pls save ur code here->https://ide.codingblocks.com/
and share the link with me

ur code is not printing carry that is generated at the end.

what should be output in this case 19, 9, 9, END or 1, 9, 9, 8, END

pls check ur chat box,i have already replied therr

now also one testcase showing wrong.\