You have $N$ wires that all extend from one location to a second distant location. The wire ends at both locations are unlabeled, and the goal is to label them all (on both ends) with distinct labels $1,2,\ldots, N$ so that the two ends of the same wire have the same label for every wire. I.e., the goal is to match every pair of wire ends.
The operations you can perform (on either end) are as follows: You can tie or untie any subset of wires together, and you can use a connectivity detector to tell if two wires are tied together on the other end. While on one of the two locations of wire ends, you can tie, untie, and test connectivity as much as you want. However, the goal is to minimize the number of trips between the two locations so that you can guarantee that you can label all the wire ends.
It seems like perhaps considering the case of even $N$ and odd $N$ separately may be a good idea, but still, is there an easy-to-describe strategy to minimize the number of trips? And prove the solution is optimal? If it helps, especially to prove optimality, we might assume that you only tie/untie wires at the starting location, and only test connectivity at the second location.