import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = "";
		int w, n;
		w = n = 0;

		Main main = new Main();
		ArrayList<Lane> lanes = new ArrayList<Main.Lane>();
		ArrayList<Rule> rules = new ArrayList<Main.Rule>();

		try {
			w = Integer.parseInt(br.readLine());
			n = Integer.parseInt(br.readLine());

			for (int i = 1; i <= w; i++) {
				lanes.add(main.new Lane(i));
			}

			while ((s = br.readLine()) != null) {
				rules.add(main.new Rule(s));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		for (Lane l : lanes) {
			for (Rule r : rules) {
				l.applyRule(r);
			}
		}
		for (int i = 1; i <= w; i++) {
			for (Lane l : lanes) {
				if (l.getCurrentLane() == i)
					System.out.println(l.getInitialLane());
			}
		}
	}

	class Lane {
		private int initial;
		private int current;

		Lane(int lane) {
			this.initial = this.current = lane;
		}

		int getInitialLane() {
			return initial;
		}

		int getCurrentLane() {
			return current;
		}

		void applyRule(Rule rule) {
			current = rule.getNewLane(current);
		}
	}

	class Rule {
		private ArrayList<Integer> pair = new ArrayList<Integer>();

		Rule(int a, int b) {
			pair.add(a);
			pair.add(b);
		}

		Rule(String s) {
			int a = Integer.parseInt((s.split(",")[0]));
			int b = Integer.parseInt((s.split(",")[1]));
			pair.add(a);
			pair.add(b);
		}

		int getNewLane(int lane) {
			if (pair.contains(lane)) {
				return (lane == pair.get(0) ? pair.get(1) : pair.get(0));
			} else {
				return lane;
			}

		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = "";
		int w, n;
		w = n = 0;

		Main main = new Main();
		ArrayList<Lane> lanes = new ArrayList<Main.Lane>();
		ArrayList<Rule> rules = new ArrayList<Main.Rule>();

		try {
			w = Integer.parseInt(br.readLine());
			n = Integer.parseInt(br.readLine());

			for (int i = 1; i <= w; i++) {
				lanes.add(main.new Lane(i));
			}

			while ((s = br.readLine()) != null) {
				rules.add(main.new Rule(s));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		for (Lane l : lanes) {
			for (Rule r : rules) {
				l.applyRule(r);
			}
		}
		for (int i = 1; i <= w; i++) {
			for (Lane l : lanes) {
				if (l.getCurrentLane() == i)
					System.out.println(l.getInitialLane());
			}
		}
	}

	class Lane {
		private int initial;
		private int current;

		Lane(int lane) {
			this.initial = this.current = lane;
		}

		int getInitialLane() {
			return initial;
		}

		int getCurrentLane() {
			return current;
		}

		void applyRule(Rule rule) {
			current = rule.getNewLane(current);
		}
	}

	class Rule {
		private ArrayList<Integer> pair = new ArrayList<Integer>();

		Rule(int a, int b) {
			pair.add(a);
			pair.add(b);
		}

		Rule(String s) {
			int a = Integer.parseInt((s.split(",")[0]));
			int b = Integer.parseInt((s.split(",")[1]));
			pair.add(a);
			pair.add(b);
		}

		int getNewLane(int lane) {
			if (pair.contains(lane)) {
				return (lane == pair.get(0) ? pair.get(1) : pair.get(0));
			} else {
				return lane;
			}

		}
	}
} Main public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = "";
		int w, n;
		w = n = 0;

		Main main = new Main();
		ArrayList<Lane> lanes = new ArrayList<Main.Lane>();
		ArrayList<Rule> rules = new ArrayList<Main.Rule>();

		try {
			w = Integer.parseInt(br.readLine());
			n = Integer.parseInt(br.readLine());

			for (int i = 1; i <= w; i++) {
				lanes.add(main.new Lane(i));
			}

			while ((s = br.readLine()) != null) {
				rules.add(main.new Rule(s));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		for (Lane l : lanes) {
			for (Rule r : rules) {
				l.applyRule(r);
			}
		}
		for (int i = 1; i <= w; i++) {
			for (Lane l : lanes) {
				if (l.getCurrentLane() == i)
					System.out.println(l.getInitialLane());
			}
		}
	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = "";
		int w, n;
		w = n = 0;

		Main main = new Main();
		ArrayList<Lane> lanes = new ArrayList<Main.Lane>();
		ArrayList<Rule> rules = new ArrayList<Main.Rule>();

		try {
			w = Integer.parseInt(br.readLine());
			n = Integer.parseInt(br.readLine());

			for (int i = 1; i <= w; i++) {
				lanes.add(main.new Lane(i));
			}

			while ((s = br.readLine()) != null) {
				rules.add(main.new Rule(s));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		for (Lane l : lanes) {
			for (Rule r : rules) {
				l.applyRule(r);
			}
		}
		for (int i = 1; i <= w; i++) {
			for (Lane l : lanes) {
				if (l.getCurrentLane() == i)
					System.out.println(l.getInitialLane());
			}
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String s = ""; s "" int w w n; n w = n = 0 w n = 0 n 0 Main main = new Main(); main new Main() ArrayList<Lane> lanes = new ArrayList<Main.Lane>(); lanes new ArrayList<Main.Lane>() ArrayList<Rule> rules = new ArrayList<Main.Rule>(); rules new ArrayList<Main.Rule>() try {
			w = Integer.parseInt(br.readLine());
			n = Integer.parseInt(br.readLine());

			for (int i = 1; i <= w; i++) {
				lanes.add(main.new Lane(i));
			}

			while ((s = br.readLine()) != null) {
				rules.add(main.new Rule(s));
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			w = Integer.parseInt(br.readLine());
			n = Integer.parseInt(br.readLine());

			for (int i = 1; i <= w; i++) {
				lanes.add(main.new Lane(i));
			}

			while ((s = br.readLine()) != null) {
				rules.add(main.new Rule(s));
			}
		} w = Integer.parseInt(br.readLine()) w Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br n = Integer.parseInt(br.readLine()) n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br for (int i = 1; i <= w; i++) {
				lanes.add(main.new Lane(i));
			} int i = 1; int i = 1; i 1 i <= w i w i++ i++ i {
				lanes.add(main.new Lane(i));
			} {
				lanes.add(main.new Lane(i));
			} lanes.add(main.new Lane(i)) lanes.add lanes main.new Lane(i) main main while ((s = br.readLine()) != null) {
				rules.add(main.new Rule(s));
			} (s = br.readLine()) != null (s = br.readLine()) s br.readLine() br.readLine br null {
				rules.add(main.new Rule(s));
			} rules.add(main.new Rule(s)) rules.add rules main.new Rule(s) main main for (Lane l : lanes) {
			for (Rule r : rules) {
				l.applyRule(r);
			}
		} Lane l lanes {
			for (Rule r : rules) {
				l.applyRule(r);
			}
		} {
			for (Rule r : rules) {
				l.applyRule(r);
			}
		} for (Rule r : rules) {
				l.applyRule(r);
			} Rule r rules {
				l.applyRule(r);
			} {
				l.applyRule(r);
			} l.applyRule(r) l.applyRule l r for (int i = 1; i <= w; i++) {
			for (Lane l : lanes) {
				if (l.getCurrentLane() == i)
					System.out.println(l.getInitialLane());
			}
		} int i = 1; int i = 1; i 1 i <= w i w i++ i++ i {
			for (Lane l : lanes) {
				if (l.getCurrentLane() == i)
					System.out.println(l.getInitialLane());
			}
		} {
			for (Lane l : lanes) {
				if (l.getCurrentLane() == i)
					System.out.println(l.getInitialLane());
			}
		} for (Lane l : lanes) {
				if (l.getCurrentLane() == i)
					System.out.println(l.getInitialLane());
			} Lane l lanes {
				if (l.getCurrentLane() == i)
					System.out.println(l.getInitialLane());
			} {
				if (l.getCurrentLane() == i)
					System.out.println(l.getInitialLane());
			} if (l.getCurrentLane() == i)
					System.out.println(l.getInitialLane()); l.getCurrentLane() == i l.getCurrentLane() l.getCurrentLane l i System.out.println(l.getInitialLane()) System.out.println System.out System System.out l.getInitialLane() l.getInitialLane l String[] args args class Lane {
		private int initial;
		private int current;

		Lane(int lane) {
			this.initial = this.current = lane;
		}

		int getInitialLane() {
			return initial;
		}

		int getCurrentLane() {
			return current;
		}

		void applyRule(Rule rule) {
			current = rule.getNewLane(current);
		}
	} Lane private int initial; initial private int current; current Lane(int lane) {
			this.initial = this.current = lane;
		} Lane {
			this.initial = this.current = lane;
		} this.initial = this.current = lane this.initial this this.initial this.current = lane this.current this this.current lane int lane lane int getInitialLane() {
			return initial;
		} getInitialLane {
			return initial;
		} return initial; initial int getCurrentLane() {
			return current;
		} getCurrentLane {
			return current;
		} return current; current void applyRule(Rule rule) {
			current = rule.getNewLane(current);
		} applyRule {
			current = rule.getNewLane(current);
		} current = rule.getNewLane(current) current rule.getNewLane(current) rule.getNewLane rule current Rule rule rule class Rule {
		private ArrayList<Integer> pair = new ArrayList<Integer>();

		Rule(int a, int b) {
			pair.add(a);
			pair.add(b);
		}

		Rule(String s) {
			int a = Integer.parseInt((s.split(",")[0]));
			int b = Integer.parseInt((s.split(",")[1]));
			pair.add(a);
			pair.add(b);
		}

		int getNewLane(int lane) {
			if (pair.contains(lane)) {
				return (lane == pair.get(0) ? pair.get(1) : pair.get(0));
			} else {
				return lane;
			}

		}
	} Rule private ArrayList<Integer> pair = new ArrayList<Integer>(); pair new ArrayList<Integer>() Rule(int a, int b) {
			pair.add(a);
			pair.add(b);
		} Rule {
			pair.add(a);
			pair.add(b);
		} pair.add(a) pair.add pair a pair.add(b) pair.add pair b int a a int b b Rule(String s) {
			int a = Integer.parseInt((s.split(",")[0]));
			int b = Integer.parseInt((s.split(",")[1]));
			pair.add(a);
			pair.add(b);
		} Rule {
			int a = Integer.parseInt((s.split(",")[0]));
			int b = Integer.parseInt((s.split(",")[1]));
			pair.add(a);
			pair.add(b);
		} int a = Integer.parseInt((s.split(",")[0])); a Integer.parseInt((s.split(",")[0])) Integer.parseInt Integer (s.split(",")[0]) s.split(",") s.split s "," 0 int b = Integer.parseInt((s.split(",")[1])); b Integer.parseInt((s.split(",")[1])) Integer.parseInt Integer (s.split(",")[1]) s.split(",") s.split s "," 1 pair.add(a) pair.add pair a pair.add(b) pair.add pair b String s s int getNewLane(int lane) {
			if (pair.contains(lane)) {
				return (lane == pair.get(0) ? pair.get(1) : pair.get(0));
			} else {
				return lane;
			}

		} getNewLane {
			if (pair.contains(lane)) {
				return (lane == pair.get(0) ? pair.get(1) : pair.get(0));
			} else {
				return lane;
			}

		} if (pair.contains(lane)) {
				return (lane == pair.get(0) ? pair.get(1) : pair.get(0));
			} else {
				return lane;
			} pair.contains(lane) pair.contains pair lane {
				return (lane == pair.get(0) ? pair.get(1) : pair.get(0));
			} return (lane == pair.get(0) ? pair.get(1) : pair.get(0)); (lane == pair.get(0) ? pair.get(1) : pair.get(0)) lane == pair.get(0) lane pair.get(0) pair.get pair 0 pair.get(1) pair.get pair 1 pair.get(0) pair.get pair 0 {
				return lane;
			} return lane; lane int lane lane public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = "";
		int w, n;
		w = n = 0;

		Main main = new Main();
		ArrayList<Lane> lanes = new ArrayList<Main.Lane>();
		ArrayList<Rule> rules = new ArrayList<Main.Rule>();

		try {
			w = Integer.parseInt(br.readLine());
			n = Integer.parseInt(br.readLine());

			for (int i = 1; i <= w; i++) {
				lanes.add(main.new Lane(i));
			}

			while ((s = br.readLine()) != null) {
				rules.add(main.new Rule(s));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		for (Lane l : lanes) {
			for (Rule r : rules) {
				l.applyRule(r);
			}
		}
		for (int i = 1; i <= w; i++) {
			for (Lane l : lanes) {
				if (l.getCurrentLane() == i)
					System.out.println(l.getInitialLane());
			}
		}
	}

	class Lane {
		private int initial;
		private int current;

		Lane(int lane) {
			this.initial = this.current = lane;
		}

		int getInitialLane() {
			return initial;
		}

		int getCurrentLane() {
			return current;
		}

		void applyRule(Rule rule) {
			current = rule.getNewLane(current);
		}
	}

	class Rule {
		private ArrayList<Integer> pair = new ArrayList<Integer>();

		Rule(int a, int b) {
			pair.add(a);
			pair.add(b);
		}

		Rule(String s) {
			int a = Integer.parseInt((s.split(",")[0]));
			int b = Integer.parseInt((s.split(",")[1]));
			pair.add(a);
			pair.add(b);
		}

		int getNewLane(int lane) {
			if (pair.contains(lane)) {
				return (lane == pair.get(0) ? pair.get(1) : pair.get(0));
			} else {
				return lane;
			}

		}
	}
} public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = "";
		int w, n;
		w = n = 0;

		Main main = new Main();
		ArrayList<Lane> lanes = new ArrayList<Main.Lane>();
		ArrayList<Rule> rules = new ArrayList<Main.Rule>();

		try {
			w = Integer.parseInt(br.readLine());
			n = Integer.parseInt(br.readLine());

			for (int i = 1; i <= w; i++) {
				lanes.add(main.new Lane(i));
			}

			while ((s = br.readLine()) != null) {
				rules.add(main.new Rule(s));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		for (Lane l : lanes) {
			for (Rule r : rules) {
				l.applyRule(r);
			}
		}
		for (int i = 1; i <= w; i++) {
			for (Lane l : lanes) {
				if (l.getCurrentLane() == i)
					System.out.println(l.getInitialLane());
			}
		}
	}

	class Lane {
		private int initial;
		private int current;

		Lane(int lane) {
			this.initial = this.current = lane;
		}

		int getInitialLane() {
			return initial;
		}

		int getCurrentLane() {
			return current;
		}

		void applyRule(Rule rule) {
			current = rule.getNewLane(current);
		}
	}

	class Rule {
		private ArrayList<Integer> pair = new ArrayList<Integer>();

		Rule(int a, int b) {
			pair.add(a);
			pair.add(b);
		}

		Rule(String s) {
			int a = Integer.parseInt((s.split(",")[0]));
			int b = Integer.parseInt((s.split(",")[1]));
			pair.add(a);
			pair.add(b);
		}

		int getNewLane(int lane) {
			if (pair.contains(lane)) {
				return (lane == pair.get(0) ? pair.get(1) : pair.get(0));
			} else {
				return lane;
			}

		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = "";
		int w, n;
		w = n = 0;

		Main main = new Main();
		ArrayList<Lane> lanes = new ArrayList<Main.Lane>();
		ArrayList<Rule> rules = new ArrayList<Main.Rule>();

		try {
			w = Integer.parseInt(br.readLine());
			n = Integer.parseInt(br.readLine());

			for (int i = 1; i <= w; i++) {
				lanes.add(main.new Lane(i));
			}

			while ((s = br.readLine()) != null) {
				rules.add(main.new Rule(s));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		for (Lane l : lanes) {
			for (Rule r : rules) {
				l.applyRule(r);
			}
		}
		for (int i = 1; i <= w; i++) {
			for (Lane l : lanes) {
				if (l.getCurrentLane() == i)
					System.out.println(l.getInitialLane());
			}
		}
	}

	class Lane {
		private int initial;
		private int current;

		Lane(int lane) {
			this.initial = this.current = lane;
		}

		int getInitialLane() {
			return initial;
		}

		int getCurrentLane() {
			return current;
		}

		void applyRule(Rule rule) {
			current = rule.getNewLane(current);
		}
	}

	class Rule {
		private ArrayList<Integer> pair = new ArrayList<Integer>();

		Rule(int a, int b) {
			pair.add(a);
			pair.add(b);
		}

		Rule(String s) {
			int a = Integer.parseInt((s.split(",")[0]));
			int b = Integer.parseInt((s.split(",")[1]));
			pair.add(a);
			pair.add(b);
		}

		int getNewLane(int lane) {
			if (pair.contains(lane)) {
				return (lane == pair.get(0) ? pair.get(1) : pair.get(0));
			} else {
				return lane;
			}

		}
	}
}