f=lambda x,y:x>[]and y.pop()+x.pop()*f(x,y)
print(f([5, 10],[4, 2]))
print(f([10, 10, 4, 62, 7],[1, 2, 3, 4, 5]))
print(f([5, 1, 10],[3, 0, 7]))
print(f([6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [3, 1, 5, 5, 3, 0, 5, 2, 5, 4]))
Zj1sYW1iZGEgeCx5Ong+W11hbmQgeS5wb3AoKSt4LnBvcCgpKmYoeCx5KQoKcHJpbnQoZihbNSwgMTBdLFs0LCAyXSkpCnByaW50KGYoWzEwLCAxMCwgNCwgNjIsIDddLFsxLCAyLCAzLCA0LCA1XSkpCnByaW50KGYoWzUsIDEsIDEwXSxbMywgMCwgN10pKQpwcmludChmKFs2LCA2LCA2LCA2LCA2LCA2LCA2LCA2LCA2LCA2XSwgWzMsIDEsIDUsIDUsIDMsIDAsIDUsIDIsIDUsIDRdKSk=