Problem of INTERSECTION POINT TWO LINKED LISTS

Sample Input
5
10 20 30 40 50
4
15 25 40 50

Sample Output
40

my code:
int aa=len(head1),bb=len(head2);
node*a=head1,*b=head2;
int c1=0,c2=0;
while(c1<aa+1)
{
while(c2<bb+1)
{
if(a->data==b->data)
cout<data;
b=b->next;
c2++;
}
a=a->next;
c1++;
}

Plz send your code by saving on ide

I HAVE SENT YOU IN HERE ONLY

No, you need to send the entire code of yours by saving on ide,

help me in learning this concept?