import java.util.*; import java.io.*; public class Q{ public static void main(String[] args){ boolean first = true; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Scanner in = new Scanner(System.in); int casenum = in.nextInt(); for(int i = 0; i < casenum; i++){ int listsize = in.nextInt(); int numtests = in.nextInt(); in.nextLine(); String goop = in.nextLine(); String[] list = goop.split("\\s+"); String[] templist = new String[(list.length + 1)]; /*for(int k = 0; k < list.length; k++){ templist[k] = list[k]; }*/ for(int j = 0; j < numtests; j++){ int a = in.nextInt() - 1; int b = in.nextInt() - 1; String temp = list[b]; templist[b] = list[a]; list[a] = null; } int m = 0; for(int l = 0; l < list.length; l++){ if (list[l] != null){ if(templist[m] == null){ templist[m] = list[l]; list[l] = null; m++; } else{ l--; m++; } } } for(int n = 0; n < list.length; n++){ if ((n+1) == list.length) System.out.println(templist[n]); else System.out.print(templist[n] + " "); } } } }The statements and opinions included in these pages are those of only. Any statements and opinions included in these pages are not those of Louisiana State University or the LSU Board of Supervisors.
© 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Isaac Traxler