Given elements as nodes of the two linked lists. The task is to multiply these two linked lists, say L_{1} and L_{2}. 
Note: The output could be large take modulo 10^{9}+7.
Example:
Input:
2
2
3 2
1
2
3
1 0 0
2
1 0 
Output:
64
1000
Explanation:
Testcase 1: 32*2 = 64.
Testcase 2: 100*10 = 1000.
Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow, the first line of each test case contains an integer N denoting the size of the first linked list (L1). In the next line are the space-separated values of the first linked list. The third line of each test case contains an integer M denoting the size of the second linked list (L2). In the fourth line is space-separated values of the second linked list.
Output:
For each test case output will be an integer denoting the product of the two linked lists.
Your Task:
The task is to complete the function multiplyTwoLists() which should multiply the given two linked lists and return the result.
Constraints:
1 <= T <= 100
1 <= N, M <= 100

Difficulty: EASY
Tags: Number theory

Data structures
Skill types: Data structures

Starter code:
MOD = 10**9+7

# your task is to complete this function

# Function should return an integer value

# head1 denotes head node of 1st list

# head2 denotes head node of 2nd list



'''

class node:

    def __init__(self):

        self.data = None

        self.next = None

'''



def multiplyTwoList(head1, head2):

    # Code here



Solutions:
MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	no_1 = ''
	no_2 = ''
	i = head1
	while i:
		no_1 += str(i.data)
		i = i.next
	j = head2
	while j:
		no_2 += str(j.data)
		j = j.next
	ans = int(no_1) * int(no_2)
	ans = str(ans % (10 ** 9 + 7))
	return ans


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	curr1 = head1
	curr2 = head2
	a1 = 0
	a2 = 0
	while curr1 is not None:
		a1 = (a1 * 10 + curr1.data) % MOD
		curr1 = curr1.next
	while curr2 is not None:
		a2 = (a2 * 10 + curr2.data) % MOD
		curr2 = curr2.next
	return a1 * a2 % MOD


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	one = 0
	two = 0
	while head1 or head2:
		if head1:
			one = (one * 10 + head1.data) % MOD
			head1 = head1.next
		if head2:
			two = (two * 10 + head2.data) % MOD
			head2 = head2.next
	return one * two % MOD


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	num1 = 0
	num2 = 0
	while head1:
		num1 = num1 * 10 + head1.data
		head1 = head1.next
	while head2:
		num2 = num2 * 10 + head2.data
		head2 = head2.next
	return num1 * num2 % MOD


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	x = ''
	ptr = head1
	while ptr != None:
		x += str(ptr.data)
		ptr = ptr.next
	x += '*'
	ptr = head2
	while ptr != None:
		x += str(ptr.data)
		ptr = ptr.next
	res = eval(x)
	res = res % (10 ** 9 + 7)
	return res


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	s1 = ''
	front1 = head1
	s2 = ''
	front2 = head2
	while front1 is not None:
		s1 += str(front1.data)
		front1 = front1.next
	while front2 is not None:
		s2 += str(front2.data)
		front2 = front2.next
	return int(s1) * int(s2) % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	temp = head1
	l1 = ''
	l2 = ''
	while temp:
		l1 += str(temp.data)
		temp = temp.next
	temp = head2
	while temp:
		l2 += str(temp.data)
		temp = temp.next
	res = int(int(l1) * int(l2)) % 1000000007
	return res


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	n1 = ''
	n2 = ''
	curr1 = head1
	curr2 = head2
	while curr1 != None:
		n1 = n1 + str(curr1.data)
		curr1 = curr1.next
	while curr2 != None:
		n2 = n2 + str(curr2.data)
		curr2 = curr2.next
	answer = int(n1) * int(n2)
	return answer % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	num1 = 0
	num2 = 0
	curr = head1
	temp = head2
	while curr != None or temp != None:
		if curr != None:
			num1 = num1 * 10 + curr.data
			curr = curr.next
		if temp != None:
			num2 = num2 * 10 + temp.data
			temp = temp.next
	result = num1 * num2
	return result % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	p = head1
	q = head2
	a = ''
	b = ''
	while p:
		a += str(p.data)
		p = p.next
	while q:
		b += str(q.data)
		q = q.next
	return int(a) * int(b) % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	s1 = 0
	s2 = 0
	while head1 or head2:
		if head1:
			s1 = (s1 * 10 + head1.data) % MOD
			head1 = head1.next
		if head2:
			s2 = (s2 * 10 + head2.data) % MOD
			head2 = head2.next
	return s1 * s2 % MOD


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	temp1 = head1
	temp2 = head2
	s1 = ''
	s2 = ''
	while temp1 != None:
		s1 += str(temp1.data)
		temp1 = temp1.next
	while temp2 != None:
		s2 += str(temp2.data)
		temp2 = temp2.next
	s = int(s1) * int(s2) % (10 ** 9 + 7)
	return s


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	s1 = ''
	s2 = ''
	temp1 = head1
	temp2 = head2
	while temp1:
		s1 += str(temp1.data)
		temp1 = temp1.next
	while temp2:
		s2 += str(temp2.data)
		temp2 = temp2.next
	ans = int(int(s1) * int(s2)) % 1000000007
	return ans


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	c1 = head1
	c2 = head2
	k1 = []
	k2 = []
	while c1 != None:
		k1.append(str(c1.data))
		c1 = c1.next
	while c2 != None:
		k2.append(str(c2.data))
		c2 = c2.next
	r1 = int(''.join(k1))
	r2 = int(''.join(k2))
	return r1 * r2 % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	a = 0
	b = 0
	while head1 and head2:
		a = 10 * a + head1.data
		b = 10 * b + head2.data
		head1 = head1.next
		head2 = head2.next
	while head1:
		a = 10 * a + head1.data
		head1 = head1.next
	while head2:
		b = 10 * b + head2.data
		head2 = head2.next
	return a * b % MOD


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	s = ''
	n = head1
	while n is not None:
		s = s + str(n.data)
		n = n.next
	s1 = ''
	n1 = head2
	while n1 is not None:
		s1 = s1 + str(n1.data)
		n1 = n1.next
	return int(s) * int(s1) % 1000000007


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	h1 = ''
	while head1:
		h1 += str(head1.data)
		head1 = head1.next
	h2 = ''
	while head2:
		h2 += str(head2.data)
		head2 = head2.next
	return int(h1) * int(h2) % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	val1 = 0
	val2 = 0
	while head1:
		val1 = (val1 * 10 + head1.data) % (pow(10, 9) + 7)
		head1 = head1.next
	while head2:
		val2 = (val2 * 10 + head2.data) % (pow(10, 9) + 7)
		head2 = head2.next
	return val1 * val2 % (pow(10, 9) + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	a = head1
	b = head2
	list1 = []
	list2 = []
	while a is not None:
		list1.append(str(a.data))
		a = a.next
	while b is not None:
		list2.append(str(b.data))
		b = b.next
	str1 = str(int(''.join(list1)) * int(''.join(list2)))
	return int(str1) % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	s = ''
	while head1:
		s = s + str(head1.data)
		head1 = head1.next
	s1 = ''
	while head2:
		s1 = s1 + str(head2.data)
		head2 = head2.next
	s = int(s) * int(s1)
	return s % MOD


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	arr = ''
	arr1 = ''
	while head1:
		arr = arr + str(head1.data)
		head1 = head1.next
	while head2:
		arr1 = arr1 + str(head2.data)
		head2 = head2.next
	return int(arr) * int(arr1) % MOD


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	curr1 = head1
	m1 = 0
	curr2 = head2
	m2 = 0
	mod = 1000000007
	while curr1 and curr2:
		m1 = (m1 * 10 + curr1.data) % mod
		curr1 = curr1.next
		m2 = (m2 * 10 + curr2.data) % mod
		curr2 = curr2.next
	while curr1:
		m1 = (m1 * 10 + curr1.data) % mod
		curr1 = curr1.next
	while curr2:
		m2 = (m2 * 10 + curr2.data) % mod
		curr2 = curr2.next
	return m1 * m2 % mod


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	a = []
	itr = head1
	while itr:
		a.append(str(itr.data))
		itr = itr.next
	b = []
	itr = head2
	while itr:
		b.append(str(itr.data))
		itr = itr.next
	a = int(''.join(a))
	b = int(''.join(b))
	return a * b % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	num1 = ''
	num2 = ''
	temp1 = head1
	temp2 = head2
	while temp1:
		num1 += str(temp1.data)
		temp1 = temp1.next
	while temp2:
		num2 += str(temp2.data)
		temp2 = temp2.next
	result = int(num1) * int(num2)
	result = result % 1000000007
	return result


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	str1 = ''
	while head1:
		str1 += str(head1.data)
		head1 = head1.next
	str2 = ''
	while head2:
		str2 += str(head2.data)
		head2 = head2.next
	return int(str1) * int(str2) % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	n1 = 0
	n2 = 0
	while head1 != None or head2 != None:
		if head1 != None:
			n1 = n1 * 10 + head1.data
			head1 = head1.next
		if head2 != None:
			n2 = n2 * 10 + head2.data
			head2 = head2.next
	return n1 * n2 % 1000000007


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	(string, string2) = ('', '')
	(curr, curr1) = (head1, head2)
	while curr:
		string += str(curr.data)
		curr = curr.next
	while curr1:
		string2 += str(curr1.data)
		curr1 = curr1.next
	return int(string) * int(string2) % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	h1 = head1
	h2 = head2
	a = b = ''
	while h1:
		a += str(h1.data)
		h1 = h1.next
	while h2:
		b += str(h2.data)
		h2 = h2.next
	c = int(a) * int(b)
	d = c % MOD
	return d


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	t = ''
	while head1 != None:
		t = t + str(head1.data)
		head1 = head1.next
	s = ''
	while head2 != None:
		s = s + str(head2.data)
		head2 = head2.next
	return int(t) * int(s) % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	num1 = 0
	num2 = 0
	mod = 1000000007
	p1 = head1
	p2 = head2
	while p1:
		num1 = (num1 * 10 + p1.data) % mod
		p1 = p1.next
	while p2:
		num2 = (num2 * 10 + p2.data) % mod
		p2 = p2.next
	return num1 * num2 % mod


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	(a, b) = (0, 0)
	(itr1, itr2) = (head1, head2)
	while itr1:
		a = a * 10 + itr1.data
		itr1 = itr1.next
	while itr2:
		b = b * 10 + itr2.data
		itr2 = itr2.next
	return a * b % 1000000007


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	no1 = ''
	no2 = ''
	temp = head1
	while temp != None:
		no1 += str(temp.data)
		temp = temp.next
	temp = head2
	while temp != None:
		no2 += str(temp.data)
		temp = temp.next
	res = int(no1) * int(no2)
	return res % (pow(10, 9) + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	l = 10 ** 9 + 7
	num1 = 0
	num2 = 0
	while head1 or head2:
		if head1:
			num1 = num1 * 10 + head1.data
			head1 = head1.next
		if head2:
			num2 = num2 * 10 + head2.data
			head2 = head2.next
	return num1 % l * (num2 % l) % l


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	num1 = 0
	num2 = 0
	N = 1000000007
	temp1 = head1
	temp2 = head2
	while temp1 != None or temp2 != None:
		if temp1 != None:
			num1 = num1 * 10 + temp1.data
			temp1 = temp1.next
		if temp2 != None:
			num2 = num2 * 10 + temp2.data
			temp2 = temp2.next
	return num1 * num2 % N


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	a = ''
	b = ''
	temp1 = head1
	temp2 = head2
	while temp1 != None:
		a += str(temp1.data)
		temp1 = temp1.next
	while temp2 != None:
		b += str(temp2.data)
		temp2 = temp2.next
	return int(a) * int(b) % 1000000007


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	temp = head1
	s1 = 0
	while temp != None:
		s1 = s1 * 10 + int(temp.data)
		temp = temp.next
	temp1 = head2
	s2 = 0
	while temp1 != None:
		s2 = s2 * 10 + int(temp1.data)
		if temp1.next:
			temp1 = temp1.next
		else:
			break
	return s1 * s2 % 1000000007


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	num1 = 0
	num2 = 0
	first = head1
	second = head2
	while first != None or second != None:
		if first != None:
			num1 = num1 * 10 + first.data
			first = first.next
		if second != None:
			num2 = num2 * 10 + second.data
			second = second.next
	ans = int(num1 * num2) % 1000000007
	return ans


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	cur1 = head1
	x = ''
	while cur1 is not None:
		x += str(cur1.data)
		cur1 = cur1.next
	cur2 = head2
	y = ''
	while cur2 is not None:
		y += str(cur2.data)
		cur2 = cur2.next
	return int(y) * int(x) % (pow(10, 9) + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	num1 = 0
	num2 = 0
	first_ptr = head1
	second_ptr = head2
	while first_ptr != None or second_ptr != None:
		if first_ptr != None:
			num1 = num1 * 10 + first_ptr.data
			first_ptr = first_ptr.next
		if second_ptr != None:
			num2 = num2 * 10 + second_ptr.data
			second_ptr = second_ptr.next
	return num1 * num2 % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	n1 = 0
	n2 = 0
	n3 = 0
	while head1:
		n1 = (n1 * 10 + head1.data) % 1000000007
		head1 = head1.next
	while head2:
		n2 = (n2 * 10 + head2.data) % 1000000007
		head2 = head2.next
	n3 = n1 * n2 % 1000000007
	return n3


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	l1 = head1
	l2 = head2
	num1 = 0
	num2 = 0
	while l1 is not None or l2 is not None:
		if l1:
			num1 = num1 * 10 + l1.data
			l1 = l1.next
		if l2:
			num2 = num2 * 10 + l2.data
			l2 = l2.next
	return num1 * num2 % (pow(10, 9) + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	ar = ''
	temp = head1
	while temp != None:
		ar += str(temp.data)
		temp = temp.next
	ar1 = ''
	temp = head2
	while temp != None:
		ar1 += str(temp.data)
		temp = temp.next
	r = int(ar) * int(ar1) % 1000000007
	return r


MOD = 10 ** 9 + 7

def reverse(head):
	t = head
	p = None
	n = None
	while t != None:
		n = t.next
		t.next = p
		p = t
		t = n
	return p

def inte(head):
	h1 = head
	c = 0
	k = 0
	while h1 != None:
		c += h1.data * 10 ** k
		h1 = h1.next
		k += 1
	return c

def multiplyTwoList(head1, head2):
	h1 = reverse(head1)
	h2 = reverse(head2)
	c1 = inte(h1)
	c2 = inte(h2)
	return c1 * c2 % MOD


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	n1 = 0
	n2 = 0
	while head1 != None:
		n1 = n1 * 10 + head1.data
		head1 = head1.next
	while head2 != None:
		n2 = n2 * 10 + head2.data
		head2 = head2.next
	return n1 * n2 % MOD


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	n1 = ''
	n2 = ''
	tmp = head1
	while tmp:
		n1 += str(tmp.data)
		tmp = tmp.next
	tmp1 = head2
	while tmp1:
		n2 += str(tmp1.data)
		tmp1 = tmp1.next
	return int(n1) * int(n2) % 1000000007


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	num1 = ''
	num2 = ''
	m = 1000000007
	while head1:
		num1 += str(head1.data)
		head1 = head1.next
	while head2:
		num2 += str(head2.data)
		head2 = head2.next
	num1 = int(num1)
	num2 = int(num2)
	return num1 * num2 % m


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	temp1 = head1
	temp2 = head2
	mod = 1000000007
	num1 = 0
	num2 = 0
	while temp1:
		num1 = (num1 * 10 + temp1.data) % mod
		temp1 = temp1.next
	while temp2:
		num2 = (num2 * 10 + temp2.data) % mod
		temp2 = temp2.next
	return num1 * num2 % mod


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	num1 = ''
	num2 = ''
	stack1 = [head1]
	stack2 = [head2]
	while len(stack1) > 0:
		current1 = stack1.pop()
		num1 += str(current1.data)
		if current1.next:
			stack1.append(current1.next)
	while len(stack2) > 0:
		current2 = stack2.pop()
		num2 += str(current2.data)
		if current2.next:
			stack2.append(current2.next)
	return int(num1) * int(num2) % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	r1 = ''
	curr = head1
	while curr:
		r1 = r1 + str(curr.data)
		curr = curr.next
	r2 = ''
	curr = head2
	while curr:
		r2 = r2 + str(curr.data)
		curr = curr.next
	x = int(r1) * int(r2)
	x = x % MOD
	return x


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	(num1, num2) = (0, 0)
	temp = head1
	while temp is not None:
		num1 = num1 * 10 + temp.data
		temp = temp.next
	temp = head2
	while temp is not None:
		num2 = num2 * 10 + temp.data
		temp = temp.next
	return num1 * num2 % MOD


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	(s1, s2) = ('', '')
	(c, c1) = (head1, head2)
	while c or c1:
		if c:
			s1 += str(c.data)
			c = c.next
		if c1:
			s2 += str(c1.data)
			c1 = c1.next
	s = int(int(s1) * int(s2)) % 1000000007
	return s


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	a = ''
	b = ''
	while head1:
		a = a + str(head1.data)
		head1 = head1.next
	while head2:
		b = b + str(head2.data)
		head2 = head2.next
	s = int(a) * int(b)
	return int(s) % 1000000007


MOD = 10 ** 9 + 7
import math

def multiplyTwoList(head_1, head_2):
	final_string = ''
	curr = head_1
	while curr is not None:
		final_string = final_string + str(curr.data)
		curr = curr.next
	int_1 = int(final_string)
	final_string = ''
	curr = head_2
	while curr is not None:
		final_string = final_string + str(curr.data)
		curr = curr.next
	int_2 = int(final_string)
	return int_1 * int_2 % (int(math.pow(10, 9)) + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	t1 = head1
	t2 = head2
	s1 = s2 = ''
	while t1:
		s1 += str(t1.data)
		t1 = t1.next
	while t2:
		s2 += str(t2.data)
		t2 = t2.next
	s1 = int(s1)
	s2 = int(s2)
	p = int(s1 * s2) % 1000000007
	return p


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	t1 = head1
	ts1 = ''
	while t1:
		ts1 += str(t1.data)
		t1 = t1.next
	t2 = head2
	ts2 = ''
	while t2:
		ts2 += str(t2.data)
		t2 = t2.next
	return int(ts1) * int(ts2) % MOD


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	s = ''
	k = ''
	temp = head1
	while temp is not None:
		s = s + str(temp.data)
		temp = temp.next
	temp1 = head2
	while temp1 is not None:
		k = k + str(temp1.data)
		temp1 = temp1.next
	d = int(s) * int(k)
	return d % MOD


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	mul = 0
	mul2 = 0
	p = head1
	q = head2
	mod = 1000000000 + 7
	while p:
		mul = mul * 10 + p.data
		p = p.next
	while q:
		mul2 = mul2 * 10 + q.data
		q = q.next
	final = mul * mul2
	return final % mod


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	val1 = 0
	while head1 != None:
		val1 = val1 * 10 + head1.data
		head1 = head1.next
	val2 = 0
	while head2 != None:
		val2 = val2 * 10 + head2.data
		head2 = head2.next
	return val1 % 1000000007 * (val2 % 1000000007) % 1000000007


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	f = 0
	s = 0
	t = head1
	g = head2
	while t:
		f = f * 10 + t.data
		t = t.next
	while g:
		s = s * 10 + g.data
		g = g.next
	return f * s % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	num1 = 0
	num2 = 0
	mod = 1000000007
	curr = head1
	prev = head2
	while curr != None:
		num1 = (num1 * 10 + curr.data) % mod
		curr = curr.next
	while prev != None:
		num2 = (num2 * 10 + prev.data) % mod
		prev = prev.next
	return num1 * num2 % mod


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	res1 = res2 = 0
	while head1 != None:
		res1 = res1 * 10 + head1.data
		head1 = head1.next
	while head2 != None:
		res2 = res2 * 10 + head2.data
		head2 = head2.next
	return res1 * res2 % 1000000007


import math
m = int(1000000000.0) + 7

def nod(n):
	if n == 0:
		return 1
	dig = int(math.log10(n)) + 1
	return dig

def multiplyTwoList(head1, head2):
	(t1, t2) = (head1, head2)
	(l1, l2) = (0, 0)
	while t1 != None:
		t = t1.data
		d = nod(t)
		l1 = l1 * int(math.pow(10, d)) + t
		t1 = t1.next
	while t2 != None:
		t = t2.data
		d = nod(t)
		l2 = l2 * int(math.pow(10, d)) + t
		t2 = t2.next
	res = l1 % m * (l2 % m) % m
	return res


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	s1 = ''
	temp = head1
	while temp is not None:
		s1 = s1 + str(temp.data)
		temp = temp.next
	i1 = int(s1)
	s2 = ''
	temp = head2
	while temp is not None:
		s2 = s2 + str(temp.data)
		temp = temp.next
	i2 = int(s2)
	return i1 * i2 % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	num1 = ''
	num2 = ''
	while head1 != None:
		num1 += str(head1.data)
		head1 = head1.next
	while head2 != None:
		num2 += str(head2.data)
		head2 = head2.next
	return int(num1) * int(num2) % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	p = head1
	(sum1, sum2) = (0, 0)
	p2 = head2
	while p:
		sum1 = sum1 * 10 + p.data
		p = p.next
	while p2:
		sum2 = sum2 * 10 + p2.data
		p2 = p2.next
	return sum1 * sum2 % MOD


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	(h1, h2) = (0, 0)
	mod = 1000000007
	while head1:
		h1 = (h1 * 10 + head1.data) % mod
		head1 = head1.next
	while head2:
		h2 = (h2 * 10 + head2.data) % mod
		head2 = head2.next
	return h1 * h2 % mod


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	t = head1
	m = head2
	l1 = []
	l2 = []
	while t:
		l1.append(str(t.data))
		t = t.next
	while m:
		l2.append(str(m.data))
		m = m.next
	s1 = ''
	s2 = ''
	s1 = ''.join(l1)
	s2 = ''.join(l2)
	return int(s1) * int(s2) % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	l1 = l2 = 0
	temp1 = head1
	temp2 = head2
	while temp1 is not None:
		l1 += 1
		temp1 = temp1.next
	while temp2 is not None:
		l2 += 1
		temp2 = temp2.next
	temp1 = head1
	temp2 = head2
	n1 = n2 = 0
	while temp1 is not None:
		n1 += temp1.data * 10 ** (l1 - 1)
		temp1 = temp1.next
		l1 -= 1
	while temp2 is not None:
		n2 += temp2.data * 10 ** (l2 - 1)
		temp2 = temp2.next
		l2 -= 1
	return n1 * n2 % MOD


MOD = 10 ** 9 + 7

def solve(head):
	x = 0
	while head:
		x = x * 10 + head.data
		head = head.next
	return x

def multiplyTwoList(head1, head2):
	a = solve(head1)
	b = solve(head2)
	return a * b % MOD


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	l1 = []
	l2 = []
	while head1:
		l1.append(str(head1.data))
		head1 = head1.next
	while head2:
		l2.append(str(head2.data))
		head2 = head2.next
	n1 = int(''.join(l1))
	n2 = int(''.join(l2))
	return n1 * n2 % (10 ** 9 + 7)


MOD = 10 ** 9 + 7

def multiplyTwoList(head1, head2):
	x = ''
	y = ''
	cur = head1
	while cur.next:
		i = cur.data
		x += str(i)
		cur = cur.next
	x += str(cur.data)
	cur2 = head2
	while cur2.next:
		i = cur2.data
		y += str(i)
		cur2 = cur2.next
	y += str(cur2.data)
	return int(x) * int(y) % MOD


MOD = 10 ** 9 + 7

def add(data):
	new = node()
	new.data = data
	new.next = None
	return new

def strtoLL(s, head):
	head = add(s[0])
	cur = head
	for i in range(len(s) - 1):
		cur.next = add(s[i + 1])
		cur = cur.next
	return head

def multiplyTwoList(head1, head2):
	a = head1
	b = head2
	s1 = ''
	s2 = ''
	while a:
		s1 += str(a.data)
		a = a.next
	while b:
		s2 += str(b.data)
		b = b.next
	ans = int(s1) * int(s2) % MOD
	return ans