Go: package main

import "fmt"

func main() {
	var w, n, a, b, i, te int
	var amida [31]int
	fmt.Scanf("%d", &w)
	fmt.Scanf("%d", &n)
	for i := 1; i <= w; i++ {
		amida[i] = i
	}
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d,%d", &a, &b)
		te = amida[a]
		amida[a] = amida[b]
		amida[b] = te
	}
	for i := i; i <= w; i++ {
		fmt.Printf("%d\n", amida[i])
	}
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main(){
	int w, n; cin >> w >> n;
	vi x(w);
	rep(i, w) x[i] = i + 1;
	rep(i, n) {
		int a, b; char c; cin >> a >> c >> b;
		swap(x[a - 1], x[b - 1]);
	}
	rep(i, w) cout << x[i] << endl;
	
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <istream>
#include <iomanip>
 
#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(int argc, char **argv){
	int w = 0;
	int n = 0;
	int a = 0;
	int b = 0;
	char tmp = 0;
	std::vector<int> z;
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

#if INPUT_FROM_FILE
	ifs >> w >> n;
#else
	std::cin >> w >> n;
#endif

	z.resize(w);
	for(int i = 0; i < w; i++){
		z[i] = i + 1;
	}
	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> a >> tmp >> b;
#else
		std::cin >> a >> tmp >>  b;
#endif
		std::swap(z[a - 1], z[b - 1]);
	}
	for(int i = 0; i < w; i++){
		std::cout << z[i] << std::endl;
	}
	return 0;
}

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

int main(){
	int w, n, num[31], damy, i, j, bou1, bou2;

	cin >> w >> n;

	for(i = i; i <= w; i++){
		num[i] = i;
	}

	for(i = 0; i < n; i++){
		scanf("%d,%d", &bou1, &bou2);
		damy = num[bou1];
		num[bou1] = num [bou2];
		num[bou2] = damy;
	}

	for(i = 1; i <= w; i++){
		cout << num[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define dbg(x) cout << #x"="<< (x) << endl
#define fi first
#define se second

vector<int> change(vector<int> x,int k,int l){
	vector<int> m=x;
	x[k] = m[l];
	x[l] = m[k];
	return x;
}

int main(){
	int w,n;
	cin >> w;
	cin >> n;
	vector<int> ans(w);
	rep(i,w){
		ans[i]=i+1;
	}
	vector<int> m = ans;
	pair<int,int> a;
	string b;
	rep(i,n){
		cin >> b;
		sscanf(b.c_str(),"%d,%d",&a.fi,&a.se);
		m=ans;
		ans[a.fi-1] = m[a.se-1];
		ans[a.se-1] = m[a.fi-1];
	}
	rep(i,w){
		cout << ans[i] << endl;
	}
	
}

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

int main()
{
	int w,n;
	cin >> w >> n;
	vector<int> line;
	for(int i=0; i<w; ++i)
	{
		line.push_back(i);
	}

	for(int i=0; i<n; ++i)
	{
		string str;
		cin >> str;
		int dot = str.find(',');
		string numa = str.substr( 0, dot );
		string numb = str.substr( dot+1, str.size()-1 );
		int A,B;
		istrstream( numa.data() ) >> A;
		istrstream( numb.data() ) >> B;
		--A;
		--B;
		int x = line[A];
		line[A] = line[B];
		line[B] = x;
	}

	for(int i=0; i<w; ++i)
	{
		cout << line[i]+1 << '\n';
	}
}

C++: #include<iostream>
#include<cstdio>

using namespace std;

void change(int *x, int *y);

int main(void){
	int w,n;
	int p[31];
	int a, b;
	cin >> w;
	cin >> n;
	
	for(int i = 1; i <= w; i++){
		p[i] = i;
	}
	
	for(int j = 0; j < n; j++){
		scanf("%d,%d", &a, &b);
		change(&p[a], &p[b]);
		
	}
	for(int i = 1; i <= w; i++){
		cout << p[i] << endl;
	}
	return 0;
}

void change(int *x, int *y){
	int type = *x;
	*x = *y;
	*y = type;
}

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

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

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

C++: #define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;

int w, n;
int ans[30];
int main()
{
    cin >> w >> n;
    REP(i, w) {
        ans[i] =i + 1;
    }
    REP(i, n) {
        char c;
        int a, b;
        cin >> a >> c >> b;
        a--;b--;
        int tmp = ans[a];
        ans[a] = ans[b];
        ans[b] = tmp;
    }
    REP(i, w) {
        cout << ans[i] << endl;
    }
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[])
{
    int w,n,x,y;
    scanf("%d ", &w);
    int *ar = new int[w];
    for (int i = 0; i < w; i++) {
        ar[i] = i + 1;
    }

    scanf("%d ", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d,%d ", &x, &y);
        swap(ar[x - 1], ar[y - 1]);
    }
    for (int i = 0; i < w; i++) {
        printf("%d\n", ar[i]);
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    int w,n;//1~wまでの番号を用意、ｎ回の操作
    int a[30]={-1};
    int j,k;
    int temp,temp1;
    
    while(cin >> w){
        
        if(w==0)break;

        for(int i=0;i<w;i++){
            a[i]=i+1;
        }
        
        cin >> n;
    //コンマの入力,temp使用        
        for(int i=0;i<n;i++){
            cin >> j  >> temp >> k;
            temp1=a[k];
            a[j]=a[k];
            a[k]=temp1;
        }

        for(int i=0;i<w;i++){
            cout << a[i] << " ";
        }
        cout << a[w-1] << endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>

int main(int argc, char *argv[]) {
	using namespace std;
	
	int vertNum, horiNum;
	fscanf(stdin, "%d", &vertNum);
	fscanf(stdin, "%d", &horiNum);
	
	vector<int> list(vertNum);
	for (int i = 0; i < vertNum; i++) {
		list[i] = i+1;
	}
	
	int tmp1, tmp2;
	for (int i = 0; i < horiNum; i++) {
		fscanf(stdin, "%d,%d", &tmp1, &tmp2);
		swap(list[tmp1-1], list[tmp2-1]);
	}
	
	for (int i = 0; i < vertNum; i++) {
		printf("%d\n", list[i]);
	}
	return 0;
}

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

int main(){

	int w, n;
	int num[30] = { 0 };
	int a, b;

	cin >> w;
	cin >> n;

	for (int i = 0; i<w; i++)
		num[i] = i + 1;

	for (int i = 0; i<n; i++){

		cin >> a >> b;

		int tmp = num[a-1];
		num[a-1] = num[b-1];
		num[b-1] = tmp;


	}


	for (int i = 0; i<w; i++)
		cout << num[i] << "\n";

	return 0;

}

C++: #include <bits/stdc++.h>
using namespace std;

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