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 <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i, f, n) for (int i = f; i < n; ++i)
#define rep(i, n) reep(i, 0, n)


int main(){
    int w,n,a,b,t;
    int arr[30];
    scanf("%d", &w);
    scanf("%d", &n);
    rep(i,w) arr[i] = i+1;
    while(n--) {
        scanf("%d,%d", &a, &b);
        t = arr[a-1];
        arr[a-1] = arr[b-1];
        arr[b-1] = t;
    }
    rep(i,w) printf("%d\n", arr[i]);
}

C++: #include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main(){
    int w, n;
    int d[31];
    while(cin >> w >> n){
        for(int i=1;i<=w;i++) d[i] = i;
        for(int i=0;i<n;i++){
            string s; cin >> s;
            istringstream iss(s);
            for(int j=0;j<s.size();j++)
                if(s[j]==',') s[j] = ' ';
            int a, b; iss >> a >> b;
            swap(d[a], d[b]);
        }
        for(int i=1;i<=w;i++) cout << d[i] << endl;
    }
}

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

int main() {
int w,n; cin >> w >> n;
int a[31];
rep(i,0,w) a[i] = i+1;

rep(i,0,n) {
int x,y;
scanf("%d,%d",x,y);
swap(a[x-1],a[y-1]);
}
rep(i,0,n) cout << a[i] << endl;
return 0;
}

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

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

C++: #pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int inf = 0x3f3f3f3f;
//#define LOCAL



int main(int argc, char * argv[]) 
{
	#ifdef LOCAL
	freopen("/Users/huangjiaming/Documents/Algorithm/oj/data.in", "r", stdin);
	//freopen("/Users/huangjiaming/Documents/Algorithm/oj/data.out", "w", stdout);
	#endif

	int w, n, a[50], f, s;

	while (~scanf("%d", &w))
	{
		for (int i = 1; i <= w; i++)
			a[i] = i;
		scanf("%d", &n);
		while(n--)
		{
			scanf("%d,%d", &f, &s);
			swap(a[f], a[s]);
		}
		for (int i = 1; i <= w; i++)
			printf("%d\n", a[i]);
	}

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int w,n,a,b;
    char c;
    std::deque<int> deq;
    cin >> w;
    for (int i=1;i<w+1;i++) {
        deq[i]=i;
    }
    cin >> n;
    for (int j=0;j<n;j++) {
        cin >> a >> c >> b;
        /*
        int a = x.at(0)-48;
        int b = x.at(2)-48;
        int tmp = deq[b];
        deq[b] = deq[a];
        deq[a] = tmp;*/
        swap(deq[a],deq[b]);
    }
    for (int k=1;k<w+1;k++) {
        cout << deq[k] << endl;
    }
    deq.clear();
}

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

void initilize(int w,int num[]){
	for(int i=0;i<w;i++)
		num[i]=i+1;
}

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

C++: //AOJ Drowng Lots

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int w, n;
	int a[30], b[30];
	int x[30];
	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[i], &b[i]);
		a[i]--;
		b[i]--;
		swap(x[a[i]], x[b[i]]);
	}
	for(int i = 0; i < w; i++) {
		cout << x[i] << endl;
	}
	return 0;
}

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

void swap(int &a, int &b) {
	a = a ^ b;
	b = a ^ b;
	a = a ^ b;
}

int main() {
	int W, N;
	cin >> W >> N;
	int start[W];
	for (int w = 0; w != W; ++w) {
		start[w] = w+1;
	}

	int a, b, throwaway;

	for (int n = 0; n != N; ++n) {
		cin >> a;
		cin.get();
		cin >> b;
		swap(start[a-1], start[b-1]);
	}

	for (int w = 0; w != W; ++w) {
		cout << start[w] << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int n;
int a[1000000];
int sum[1000000];
int main(int argc, char const *argv[])
{

	int tc[30];
	cin>>tc[30];
	int w,v;
	for (int i = 0; i < 30; ++i) tc[i] = i+1;
		for (int i = 0; i < v; ++i)
		{
			int a,b;
			cin>>a>>b;
			int c=tc[a-1];
			tc[a-1]=tc[b-1];
			tc[b-1];

		}
		for (int i = 0; i < strlen(a); ++i)
		
			cout<<t[i]<<endl;
		
		
		
			
		
	    		
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int w,n,a[30],b[30],result[30];
  for(int i=0;i<30;i++){
    result[i]=i+1;
  }
  
  cin >>w>>n;
  for(int i=0;i<n;i++){
    scanf("%d,%d",&a[i],&b[i]);
    swap(result[a[i]-1],result[b[i]-1]);
  }

  for(int i=0;i<w;i++) cout <<result[i]<<endl;
 
  return 0;
}

C++: #include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <queue>
#include <vector>

using namespace std;

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

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

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  int i, temp;
  int w, n, ai, bi;

  cin >> w;
  cin >> n;

  vector<int> amida;

  // initialize
  for (i = 0; i < w; i++) {
    amida.push_back(i + 1);
  }

  for (i = 0; i < n; i++) {
    scanf("%d,%d", &ai, &bi);

    // swap
    temp = amida.at(ai - 1);
    amida.at(ai - 1) = amida.at(bi - 1);
    amida.at(bi - 1) = temp;
  }

  for (i = 0; i < w; i++) {
    cout << amida.at(i) << endl;
  }

  return 0;
}

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


int main()
{
	int w, n, num[31];
	string s;
	cin >> w;
	fill(num, num + 31, 0);
	for (int i = 1; i < w + 1; i++){
		num[i] = i;
	}
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		string l, r;
		int commapos;

		//カンマの左
		for (int i = 0;; i++){
			if (s[i] == ','){
				commapos = i;
				break;
			}
			else{
				l += s[i];
			}
		}

		//カンマの右
		for (int i = commapos + 1; i < (signed)s.length(); i++){
			r += s[i];
		}
		int left = atoi(l.c_str());
		int right = atoi(r.c_str());
		int temp = num[left];
		num[left] = num[right];
		num[right] = temp;
	}
	for (int i = 1; i < w + 1; i++){
		cout << num[i] << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int w, n, a, b, r[30];

int main() {
	scanf("%d %d",&w,&n);
	rep(i,w) r[i] = i+1;
	rep(i,n) {
		scanf("%d,%d",&a,&b);
		swap(r[a-1], r[b-1]);
	}
	rep(i,w) printf("%d\n",r[i]);
}