void makePairs() {
        if (res > 1)
            return;
        
        boolean allVisited = true;
        for (int i = 0; i < N; i++) {
            allVisited &= visited[i];            
        }
        
        if (allVisited) {
            res++;
            return;
        }
        
        for (int index = 0; index < N; index++)
            for (int i = 0; i < N; i++) {
                if (friends[index][i] && !visited[i]) {
                    visited[index] = true;
                    visited[i] = true;
                    makePairs();
                    visited[index] = false;
                    visited[i] = false;
                }
            }
    }