class Solution:
def addInList(self , head1 , head2 ):
# write code here
sum1=''
sum2=''
while head1 is not None:
p=head1.next
f=head1.val
head1=p
sum1+=str(f)
while head2 is not None:
s=head2.next
j=head2.val
head2=s
sum2+=str(j)
t=int(sum1)+int(sum2)
t=str(t)
s=ListNode(int(t[0]))
self.head3=ListNode(int(t[0]))
p=self.head3
for i in range(1,len(t)):
node=ListNode(int(t[i]))
p.next=node
p=p.next
return self.head3