Union and intersection of two sorted linked lists