Merge sorted link list

my code is running perfectly on sublime text 3 . but here it is showing ‘run error’.
what is the mistake?

initialize head1 and head2 with null and take input