private void processPair(Pair pair) {
        int l = pair.left;
        int r = pair.right;
        if (out[l] || out[r]) return;
        if (prev[l] != l && next[r] != r) {
            next[prev[l]] = next[r];
            prev[next[r]] = prev[l];
            int l2 = prev[l];
            int r2 = next[r];
            if (gender[l2] != gender[r2]) {
                queue.add(new Pair(l2, r2, calcSkillDiff(l2, r2)));
            }
        } else if (next[r] != r) {
            prev[next[r]] = next[r];
        } else if (prev[l] != l) {
            next[prev[l]] = prev[l];
        }
        System.out.printf("%d %d\n", l+1, r+1);
        out[l] = out[r] = true;
    }