import java.io.*;
import java.util.ArrayList;
import java.util.List;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line; // ??\???????????????????????\???
            int cnt = 0;
            List<Integer> numList = new ArrayList<Integer>();
            int row = 0;
            int column = 0;
            while ((line = br.readLine()) != null) {
            	if(cnt == 0){
            		cnt++;
            		row = Integer.parseInt(line);
            		for(int i = 1; i < row+1; i++){
            			numList.add(i);
            		}
            	}else if(cnt == 1){
            		cnt++;
            		column = Integer.parseInt(line);
            	}else{
            		String[] convertList = line.split(",", 0);
            		int first = Integer.parseInt(convertList[0]);
            		int second = Integer.parseInt(convertList[1]);
            		
            		int firstNum = numList.get(first - 1);
            		int secondNum = numList.get(second - 1);
            		
            		numList.set(first - 1, secondNum);
            		numList.set(second - 1, firstNum);
            	}  	
            }
            for(int j = 0; j < numList.size(); j++){
        		System.out.println(numList.get(j));
        	}
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
} import java.io.*; io.* java import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line; // ??\???????????????????????\???
            int cnt = 0;
            List<Integer> numList = new ArrayList<Integer>();
            int row = 0;
            int column = 0;
            while ((line = br.readLine()) != null) {
            	if(cnt == 0){
            		cnt++;
            		row = Integer.parseInt(line);
            		for(int i = 1; i < row+1; i++){
            			numList.add(i);
            		}
            	}else if(cnt == 1){
            		cnt++;
            		column = Integer.parseInt(line);
            	}else{
            		String[] convertList = line.split(",", 0);
            		int first = Integer.parseInt(convertList[0]);
            		int second = Integer.parseInt(convertList[1]);
            		
            		int firstNum = numList.get(first - 1);
            		int secondNum = numList.get(second - 1);
            		
            		numList.set(first - 1, secondNum);
            		numList.set(second - 1, firstNum);
            	}  	
            }
            for(int j = 0; j < numList.size(); j++){
        		System.out.println(numList.get(j));
        	}
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
} Main public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line; // ??\???????????????????????\???
            int cnt = 0;
            List<Integer> numList = new ArrayList<Integer>();
            int row = 0;
            int column = 0;
            while ((line = br.readLine()) != null) {
            	if(cnt == 0){
            		cnt++;
            		row = Integer.parseInt(line);
            		for(int i = 1; i < row+1; i++){
            			numList.add(i);
            		}
            	}else if(cnt == 1){
            		cnt++;
            		column = Integer.parseInt(line);
            	}else{
            		String[] convertList = line.split(",", 0);
            		int first = Integer.parseInt(convertList[0]);
            		int second = Integer.parseInt(convertList[1]);
            		
            		int firstNum = numList.get(first - 1);
            		int secondNum = numList.get(second - 1);
            		
            		numList.set(first - 1, secondNum);
            		numList.set(second - 1, firstNum);
            	}  	
            }
            for(int j = 0; j < numList.size(); j++){
        		System.out.println(numList.get(j));
        	}
        } catch (Exception e) {
            e.printStackTrace();
        }
    } main {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line; // ??\???????????????????????\???
            int cnt = 0;
            List<Integer> numList = new ArrayList<Integer>();
            int row = 0;
            int column = 0;
            while ((line = br.readLine()) != null) {
            	if(cnt == 0){
            		cnt++;
            		row = Integer.parseInt(line);
            		for(int i = 1; i < row+1; i++){
            			numList.add(i);
            		}
            	}else if(cnt == 1){
            		cnt++;
            		column = Integer.parseInt(line);
            	}else{
            		String[] convertList = line.split(",", 0);
            		int first = Integer.parseInt(convertList[0]);
            		int second = Integer.parseInt(convertList[1]);
            		
            		int firstNum = numList.get(first - 1);
            		int secondNum = numList.get(second - 1);
            		
            		numList.set(first - 1, secondNum);
            		numList.set(second - 1, firstNum);
            	}  	
            }
            for(int j = 0; j < numList.size(); j++){
        		System.out.println(numList.get(j));
        	}
        } catch (Exception e) {
            e.printStackTrace();
        }
    } try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line; // ??\???????????????????????\???
            int cnt = 0;
            List<Integer> numList = new ArrayList<Integer>();
            int row = 0;
            int column = 0;
            while ((line = br.readLine()) != null) {
            	if(cnt == 0){
            		cnt++;
            		row = Integer.parseInt(line);
            		for(int i = 1; i < row+1; i++){
            			numList.add(i);
            		}
            	}else if(cnt == 1){
            		cnt++;
            		column = Integer.parseInt(line);
            	}else{
            		String[] convertList = line.split(",", 0);
            		int first = Integer.parseInt(convertList[0]);
            		int second = Integer.parseInt(convertList[1]);
            		
            		int firstNum = numList.get(first - 1);
            		int secondNum = numList.get(second - 1);
            		
            		numList.set(first - 1, secondNum);
            		numList.set(second - 1, firstNum);
            	}  	
            }
            for(int j = 0; j < numList.size(); j++){
        		System.out.println(numList.get(j));
        	}
        } catch (Exception e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } Exception e {
            e.printStackTrace();
        } e.printStackTrace() e.printStackTrace e {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line; // ??\???????????????????????\???
            int cnt = 0;
            List<Integer> numList = new ArrayList<Integer>();
            int row = 0;
            int column = 0;
            while ((line = br.readLine()) != null) {
            	if(cnt == 0){
            		cnt++;
            		row = Integer.parseInt(line);
            		for(int i = 1; i < row+1; i++){
            			numList.add(i);
            		}
            	}else if(cnt == 1){
            		cnt++;
            		column = Integer.parseInt(line);
            	}else{
            		String[] convertList = line.split(",", 0);
            		int first = Integer.parseInt(convertList[0]);
            		int second = Integer.parseInt(convertList[1]);
            		
            		int firstNum = numList.get(first - 1);
            		int secondNum = numList.get(second - 1);
            		
            		numList.set(first - 1, secondNum);
            		numList.set(second - 1, firstNum);
            	}  	
            }
            for(int j = 0; j < numList.size(); j++){
        		System.out.println(numList.get(j));
        	}
        } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line; line int cnt = 0; cnt 0 List<Integer> numList = new ArrayList<Integer>(); numList new ArrayList<Integer>() int row = 0; row 0 int column = 0; column 0 while ((line = br.readLine()) != null) {
            	if(cnt == 0){
            		cnt++;
            		row = Integer.parseInt(line);
            		for(int i = 1; i < row+1; i++){
            			numList.add(i);
            		}
            	}else if(cnt == 1){
            		cnt++;
            		column = Integer.parseInt(line);
            	}else{
            		String[] convertList = line.split(",", 0);
            		int first = Integer.parseInt(convertList[0]);
            		int second = Integer.parseInt(convertList[1]);
            		
            		int firstNum = numList.get(first - 1);
            		int secondNum = numList.get(second - 1);
            		
            		numList.set(first - 1, secondNum);
            		numList.set(second - 1, firstNum);
            	}  	
            } (line = br.readLine()) != null (line = br.readLine()) line br.readLine() br.readLine br null {
            	if(cnt == 0){
            		cnt++;
            		row = Integer.parseInt(line);
            		for(int i = 1; i < row+1; i++){
            			numList.add(i);
            		}
            	}else if(cnt == 1){
            		cnt++;
            		column = Integer.parseInt(line);
            	}else{
            		String[] convertList = line.split(",", 0);
            		int first = Integer.parseInt(convertList[0]);
            		int second = Integer.parseInt(convertList[1]);
            		
            		int firstNum = numList.get(first - 1);
            		int secondNum = numList.get(second - 1);
            		
            		numList.set(first - 1, secondNum);
            		numList.set(second - 1, firstNum);
            	}  	
            } if(cnt == 0){
            		cnt++;
            		row = Integer.parseInt(line);
            		for(int i = 1; i < row+1; i++){
            			numList.add(i);
            		}
            	}else if(cnt == 1){
            		cnt++;
            		column = Integer.parseInt(line);
            	}else{
            		String[] convertList = line.split(",", 0);
            		int first = Integer.parseInt(convertList[0]);
            		int second = Integer.parseInt(convertList[1]);
            		
            		int firstNum = numList.get(first - 1);
            		int secondNum = numList.get(second - 1);
            		
            		numList.set(first - 1, secondNum);
            		numList.set(second - 1, firstNum);
            	} cnt == 0 cnt 0 {
            		cnt++;
            		row = Integer.parseInt(line);
            		for(int i = 1; i < row+1; i++){
            			numList.add(i);
            		}
            	} cnt++ cnt row = Integer.parseInt(line) row Integer.parseInt(line) Integer.parseInt Integer line for(int i = 1; i < row+1; i++){
            			numList.add(i);
            		} int i = 1; int i = 1; i 1 i < row+1 i row+1 row 1 i++ i++ i {
            			numList.add(i);
            		} {
            			numList.add(i);
            		} numList.add(i) numList.add numList i if(cnt == 1){
            		cnt++;
            		column = Integer.parseInt(line);
            	}else{
            		String[] convertList = line.split(",", 0);
            		int first = Integer.parseInt(convertList[0]);
            		int second = Integer.parseInt(convertList[1]);
            		
            		int firstNum = numList.get(first - 1);
            		int secondNum = numList.get(second - 1);
            		
            		numList.set(first - 1, secondNum);
            		numList.set(second - 1, firstNum);
            	} cnt == 1 cnt 1 {
            		cnt++;
            		column = Integer.parseInt(line);
            	} cnt++ cnt column = Integer.parseInt(line) column Integer.parseInt(line) Integer.parseInt Integer line {
            		String[] convertList = line.split(",", 0);
            		int first = Integer.parseInt(convertList[0]);
            		int second = Integer.parseInt(convertList[1]);
            		
            		int firstNum = numList.get(first - 1);
            		int secondNum = numList.get(second - 1);
            		
            		numList.set(first - 1, secondNum);
            		numList.set(second - 1, firstNum);
            	} String[] convertList = line.split(",", 0); convertList line.split(",", 0) line.split line "," 0 int first = Integer.parseInt(convertList[0]); first Integer.parseInt(convertList[0]) Integer.parseInt Integer convertList[0] convertList 0 int second = Integer.parseInt(convertList[1]); second Integer.parseInt(convertList[1]) Integer.parseInt Integer convertList[1] convertList 1 int firstNum = numList.get(first - 1); firstNum numList.get(first - 1) numList.get numList first - 1 first 1 int secondNum = numList.get(second - 1); secondNum numList.get(second - 1) numList.get numList second - 1 second 1 numList.set(first - 1, secondNum) numList.set numList first - 1 first 1 secondNum numList.set(second - 1, firstNum) numList.set numList second - 1 second 1 firstNum for(int j = 0; j < numList.size(); j++){
        		System.out.println(numList.get(j));
        	} int j = 0; int j = 0; j 0 j < numList.size() j numList.size() numList.size numList j++ j++ j {
        		System.out.println(numList.get(j));
        	} {
        		System.out.println(numList.get(j));
        	} System.out.println(numList.get(j)) System.out.println System.out System System.out numList.get(j) numList.get numList j String[] args args
import java.io.*;
import java.util.ArrayList;
import java.util.List;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line; // ??\???????????????????????\???
            int cnt = 0;
            List<Integer> numList = new ArrayList<Integer>();
            int row = 0;
            int column = 0;
            while ((line = br.readLine()) != null) {
            	if(cnt == 0){
            		cnt++;
            		row = Integer.parseInt(line);
            		for(int i = 1; i < row+1; i++){
            			numList.add(i);
            		}
            	}else if(cnt == 1){
            		cnt++;
            		column = Integer.parseInt(line);
            	}else{
            		String[] convertList = line.split(",", 0);
            		int first = Integer.parseInt(convertList[0]);
            		int second = Integer.parseInt(convertList[1]);
            		
            		int firstNum = numList.get(first - 1);
            		int secondNum = numList.get(second - 1);
            		
            		numList.set(first - 1, secondNum);
            		numList.set(second - 1, firstNum);
            	}  	
            }
            for(int j = 0; j < numList.size(); j++){
        		System.out.println(numList.get(j));
        	}
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}