import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int m = in.nextInt();
List
oldp=p;
temp=a.lastIndexOf(p);
((LinkedList<Integer>) a).remove(temp);
a.add(temp+q,oldp);
}
for(int i:a)
{
System.out.print(i+" ");
}
}
}