/* :- seqex(test/4). */
test(C,X,Y,Z) :-  C = f(A,[1,2,3],g(a,b),B), arg(2, C, [X,Y,Z])).

?- test(A,B,C,D).