Linked List question

This is showing runtime error .Please look into it
Given two sorted linked lists. Create a linked list with common elements such that all common odd elements are before common even elements.
You just need to return the head of new linked list formed, don’t print the elements.
Input format :
Line 1 : Linked list elements of length n1 (separated by space and terminated by -1)
Line 2 : Linked list elements of length n2 (separated by space and terminated by -1)
Output format :
Updated list elements (separated by space)
My solution-https://ide.codingblocks.com/s/197273