**Problem Statement:**

There are N students in a class, numbered from 1 to N. You are given M pairs of the form (A, B), for each such pair, students A and B are friends to each other.

Given a permutation of integers from 1 to N denoting the fashion in which students are currently arranged, you can perform the following operation any number of times (possibly 0):

- Swap the positions of two students who are friends with each other.

Determine the minimum number of swaps to arrange the students in ascending order (i^{th} student at i^{th} position from start) or determine it is impossible to arrange.

So, this is the problem for which I had no solution. I have no approaches to solve the problem. Can anyone share the approach/solution (if there is any) to this problem?

I will provide samples if needed.