head
, the head node of a linked list containing unique integer values.G
, a subset of the values in the linked list.G
, where two values are connected if they appear consecutively in the linked list.N
is the length of the linked list given by head
, 1 <= N <= 10000
.[0, N - 1]
.1 <= G.length <= 10000
.G
is a subset of all values in the linked list.