Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)

	w := nextInt()
	n := nextInt()

	numbers := make([]int, w+1)
	for i := 1; i <= w; i++ {
		numbers[i] = i
	}

	for i := 0; i < n; i++ {
		line := nextString()
		words := strings.Split(line, ",")
		a, _ := strconv.Atoi(words[0])
		b, _ := strconv.Atoi(words[1])

		numbers[a], numbers[b] = numbers[b], numbers[a]
	}

	for i := 1; i <= w; i++ {
		fmt.Println(numbers[i])
	}
}

C++: #include <iostream>
#include <vector>
#include <cstdio>
using namespace std;

int main(){
  int w, n;
  //vector<int> vec;
  int array[30];
 
 cin >> w >> n;

 // for(int i = 1; i <= w; i++) vec.push_back(i);
 // for(int i = 0; i < n; i++){
 //  int a, b, c;   
 //  scanf("%a,%b", &a, &b);
 //  c = vec.at(a);
 //  vec[a] = vec.at(b);
 //  vec[b] = c;
 //}

 for(int i = 1; i <= w; i++) array[i-1] = i;
 for(int i = 0; i < n; i++){
   int a, b, c;
   scanf("%d,%d", &a, &b);
   c = array[a-1];
   array[a-1] = array[b-1];
   array[b-1] = c;
 }

 // for(int i = 0; i < vec.size(); i++) cout << vec.at(i) << endl;
 for(int i = 0; i < w; i++) cout << array[i] << endl;

  return 0;
}

C++: #include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
  int w,n,i,a,b,t;
  string s;
  cin>>w>>n;
  int num[w];
  for(i=0;i<w;i++)num[i]=i+1;
  for(i=0;i<n;i++){
    cin>>s;
    a=atoi((s.substr(0,s.find(","))).c_str());
    b=atoi((s.substr(s.find(",")+1)).c_str());
    t=num[a-1],num[a-1]=num[b-1],num[b-1]=t;
  }
  for(i=0;i<w;i++) cout<<num[i]<<endl;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(void)
{
  int w, n, i;
  int x[30];
  int a, b;

  cin >> w >> n;
  for(i = 1; i <= w; i++){
    x[i - 1] = i;
  }
  for(i = 0; i < n; i++){
    scanf("%d,%d", &a, &b);
    swap(x[a - 1], x[b - 1]);
  }
  for(i = 0; i < w; i++){
    cout << x[i] << endl;
  }

  return 0;

}

C++: #include <stdio.h>

int main(void)
{
  int w,n;
  scanf("%d", &w);
  scanf("%d", &n);
  int num[31];
  int i;
  for(i=1; i<=w; ++i){
    num[i] = i;
  }
  for(i=0; i<n; ++i){
    int a,b;
    scanf("%d,%d", &a, &b);
    int tmp = num[a];
    num[a] = num[b];
    num[b] = tmp;
  }
  for(i=1; i<=w; ++i){
    printf("%d\n", num[i]);
  }

  return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;

int main() {
	int w, n, x, y;
	string str;
	cin >> w >> n;
	int a[31];
	for (int i = 0; i <= w; i++) {
		a[i] = i;
	}
	for (int i = 0; i < n; i++) {
		cin >> str;
		x = str[0];
		y = str[2];
		int tmp = a[x-48];
		a[x-48] = a[y-48];
		a[y-48] = tmp;
	}
	for (int i = 1; i <= w; i++) {
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main (){
	int w,n,a,b;
	int c[31];
	cin>>w>>n;
	for(int i=1;i<=w;i++)c[i]=i;
	for(int i=0;i<n;i++){
		scanf("%d,%d",&a,&b);
		swap(c[a],c[b]);
	}
	for(int i=1;i<=w;i++){
		cout<<c[i]<<endl;
	}
	return 0;
}

C++: #include<iostream>
 
using namespace std;
 
int main(void){
  int lot[31];
  for(int i=1;i<=30;i++){
    lot[i]=i;
  }
  int w,n;
  cin>>w>>n;
  for(int i=0;i<n;i++){
    int a,b;
    (cin>>a).ignore()>>b;
    swap(lot[a],lot[b]);
  }
  for(int i=1;i<=w;i++){
    cout<<lot[i]<<endl;
  }
  return 0;
}

C++: #include <map>
#include <string>
#include <iostream>
#include<vector>
#include <set>
#include <cstdio>
#include<algorithm>

using namespace std;

int main()
{
	int w, n, num[31];
	int a, b, temp;
	
	for (int i=1; i<=30; i++)
		num[i] = i;
	
	cin >> w >> n;
	
	for (int i=0; i<n; i++)
	{
		scanf("%d,%d", &a, &b);
		temp = num[a];
		num[a] = num[b];
		num[b] = temp;
	}
	
	for (int i=1; i<=w; i++)
	{
		cout << num[i] << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
	int a,b;
	cin >> a;
	cin >> b;
	int c[a];
	for(int i=0;i<a;i++) c[i] = i;
	for(int i=0;i<b;i++){
		int d,e;
		char com;
		cin >> d >> com >> e;
		int f = c[d-1];
		c[d-1] = c[e-1];
		c[e-1] = f;
	}
	for(int i=0;i<a;i++) cout << c[i]+1 << endl;
}

C++: #include <stdio.h>
void swap(int *a,int *b){
	int tmp;
	tmp=*a;*a=*b;*b=tmp;
	return;
}

int main(){
	int w,n,a,b,num[31],i;
	for(i=0;i<31;i++) num[i]= i;
	scanf("%d",&w);
	scanf("%d",&n);
	while(n--){
		scanf("%d,%d",&a,&b);
		swap(&num[a],&num[b]);
	}
	for(i=1;i<w+1;i++) printf("%d\n",num[i]);
	return 0;
}

C++: #include <iostream>
using namespace std;

int main()
{
	int w, n, a, b;
	char abdata;
	int wdata[1000];
	cin >> w >> n;
	for (int i = 0; i < w; i++) {
		wdata[i] = i+1;
	}
	for (int k = 0; k < n; k++) {
		int data;
		cin >> a >> abdata >> b;
		data = wdata[a-1];
		wdata[a-1] = wdata[b-1];
		wdata[b-1] = data;
	}
	for (int y = 0; y < w; y++) {
		cout << wdata[y] << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#define MAX 31

using namespace std;

int main(void){

  int N[MAX];
  int w,n;
  int a,b;
  char ten;

  cin >> w >> n;
  for( int i = 1 ; i <= w ; i++ )N[i] = i;

  for( int i = 1 ; i <= n ; i++ ){
    cin >> a >> ten >> b;
      swap( N[a] , N[b]); //swap関数は第一引数と第二引数を交換する関数
  }
  for( int i = 1 ; i <= w ; i++ ){
    cout << N[i];
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <sstream>
using namespace std;
int main() {
  int w;
  while (cin >> w) {
    vector<int> vec;
    vec.resize(w);
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n;
    cin >> n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
      string str, tmp_a, tmp_b;
      int a, b;
      getline(cin, str);
      istringstream iss(str);
      getline(iss, tmp_a, ',');
      getline(iss, tmp_b, ',');
      a = stoi(tmp_a) - 1;
      b = stoi(tmp_b) - 1;
      int tmp = vec[a];
      vec[a] = vec[b];
      vec[b] = tmp;
    }
    for (int i = 0; i < vec.size(); ++i) {
      cout << vec[i] << endl;
    }
  }
  return 0;
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	int w, n;
	while(cin >> w) {
		cin >> n;
		vvi bar(n, vi(2));
		
		int a, b;
		char c;
		REP(i, n) {
			cin >> a >> c >> b;
			bar[i][0] = a;
			bar[i][1] = b;
		}

		vi goal(w);
		FOR(i, 1, w) {
			int cur = i;
			REP(j, n) {
				if(bar[j][0] == cur) {
					cur = bar[j][1];
					goto next;
				}
				if(bar[j][1] == cur) {
					cur = bar[j][0];
					goto next;
				}

				next:;
			}
			
			goal[cur-1] = i;
		}

		REP(i, w) {
			cout << goal[i] << endl;
		}
	}
}