Genie is trying to take a perfect photograph of his N kids lined up in a very specific order A[1…N] for their annual family album.
But his mischievous kids love to mess around! Every time Genie counts to three and clicks the camera, exactly one kid might sneak out of their position and quickly jump somewhere else in the line — just for fun.
This happens five times, resulting in five photos. Thankfully, each time only one kid pulls this trick (or none at all), and every kid promises to only misbehave once across the five photos.
Each of the 5 photos shows a lineup that differs from the original order A by at most one move.
A kid who actively moves in one photo remains still in all other photos.
The first line contains a single integer N(1 ≤ N ≤ 20,000): the number of kids.
The next 5 lines each contain N space-separated integers. Each line represents the lineup of kids in a single photo, from left to right.
All kid IDs are unique integers between 1 and 10^9.
Print a single line containing N space-separated integers: the IDs of the kids in the original intended order A.
MyKaarma • Pending