There are N people standing in a line where the person i is at the ith position initially. A sequence of moves s given by K pairs of positions ai and bi is given. At each minute