Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	lines, _ := strconv.Atoi(sc.Text())
	l := make([]int, lines)
	for i := 0; i < lines; i++ {
		l[i] = i + 1
	}

	sc.Scan()
	rows, _ := strconv.Atoi(sc.Text())
	for i := 0; i < rows; i++ {
		sc.Scan()
		s := strings.Split(sc.Text(), ",")
		a, _ := strconv.Atoi(s[0])
		b, _ := strconv.Atoi(s[1])

		l[a-1], l[b-1] = l[b-1], l[a-1]
	}
	for _, j := range l {
		fmt.Println(j)
	}
}

C++: #include <bits/stdc++.h>
//#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;


signed main() {
	int n, m; cin >> n >> m;
	vector<int> v(n);
	rep(i, n) v[i] = i + 1;
	rep(i, m) {
		string s; cin >> s;
		string s1, s2;
		bool flag = true;
		for (auto a : s) {
			if (a == ',') flag = !flag;
			else if (flag) {
				s1 = s1 + a;
			}
			else {
				s2 = s2 + a;
			}
		}
		int a, b;
		a = stoi(s1);
		b = stoi(s2);
		swap(v[a - 1], v[b - 1]);
	}
	for (auto a : v) {
		cout << a << endl;
	}
}

C++: #include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;

int sosuu(int n);

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

    }
    
}

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

int main() {
  int w, n;
  cin >> w >> n;
  vector<int> a(n), b(n);
  char c;
  for (int i = 0; i < n; ++i)
    cin >> a[i] >> c >> b[i];

  vector<int> ans(w + 1);
  for (int j = 1; j <= w; ++j)
    ans[j] = j;

  for (int i = 0; i < n; ++i)
    swap(ans[a[i]], ans[b[i]]);

  for (int j = 1; j <= w; ++j)
    cout << ans[j] << endl;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
typedef long long int LLI;
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n,m;
  char d;
  cin>>n>>m;
  vector<int>out(n);
  rep(i,n)out[i]=i+1;
  rep(i,m){
    int a,b;
    cin>>a>>d>>b;
    swap(out[a-1],out[b-1]);
  }
  rep(i,n)cout<<out[i]<<endl;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define INF 1<<25
#define LIM 1000000

using namespace std;

int bar[30];
int w, n;

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

C++: #include <iostream>
#include<math.h>
#include <vector>
#include <string>
#include<stdio.h>
using namespace std;

class Amidakuji{

public:
	int W;
	vector<int> array;//????´?1???????????????
	Amidakuji(int w);
	void Swap(int x,int y);
	void call();
};

//????????????????????????????????????
Amidakuji::Amidakuji(int w){

	for (int i = 0; i < w; i++){
		array.push_back(i+1);//[0,1,2,3,4]={1,2,3,4,5}
	}
	
	W = w;

}

void Amidakuji::Swap(int x,int y){

	//???????????£????????????array[]???????????????
	//int?????§???????????£????????§char???int?????????????????????-48;
	x -= 48;
	y -= 48;
	int q;
	q = array[x - 1];
	array[x-1] = array[y-1];
	array[y-1] = q;
	

}

void Amidakuji::call(){

	for (int i = 0; i<W; i++){
		cout << array[i] << endl;
	}

}

int main(){

	int w, n;
	string text;

	while (cin >> w>>n){
		cin.ignore();
		//??????????????????????????§???????????????
		Amidakuji Amidakuji(w);
		for (int i = 0; i < n; i++){
			getline(cin, text);
			if (text[0] != 0 && text[2] != 0){
				//???????????????????????????swap???????????????
				Amidakuji.Swap(text[0], text[2]);
				text[0] = text[2] = 0;
			}
		}
	
		//????????????
		Amidakuji.call();
	}


	return 0;
}

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

using namespace std;

void Swap(vector<int>& v, int index1, int index2) {
    int tmp = v[index1];
    v[index1] = v[index2];
    v[index2] = tmp;
}


int main() {
    int w;
    cin >> w;

    vector<int> v(w);
    for(int i = 0; i < v.size(); ++i) {
        v[i] = i + 1;
    }
    
    int n;
    cin >> n;

    for(int i = 0, a, b; i < n; ++i) {
        cin >> a;
        cin.ignore();
        cin >> b;

        Swap(v, a - 1, b - 1);
    }

    for(auto x : v) {
        cout << x << '\n';
    }

    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

int a[50],b[50];

int main(){

	int w,h;
	cin>>w>>h;
	for (int i = 0; i < h; i++)
	{
		char c;
		cin>>a[i]>>c>>b[i];
		a[i]--; b[i]--;
	}

	vector<int> v(w);
	for (int i = 0; i < w; i++)
	{
		v[i] = i+1;
	}

	for (int i = 0; i < h; i++)
	{
		swap(v[a[i]],v[b[i]]);
	}

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


	return 0;
}

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

using namespace std;

void change(int *, int *);

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>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define rep(I,N) for(int I = 0; I < (int)(N); I++)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);


int main(void){
	int w, n;
	cin >> w >> n;
	vector<int> v;
	rep(i, w){
		v.pb(i+1);
	}
	rep(i, n){
		int a,b;
		char c;
		cin >> a >> c >> b;
		swap(v[a-1], v[b-1]);
	}
	rep(i, v.size()){
		FIN(v[i]);
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

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[j-1];
            a[j-1]=a[k-1];
            a[k-1]=temp1;

        }

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

    return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){

	int w,n,left,right;
	scanf("%d",&w);
	int array[w+1];
	for(int i=0;i<w+1;i++)array[i]=i;
	scanf("%d",&n);

	for(int i=0;i<n;i++){
		scanf("%d,%d",&left,&right);
		swap(array[left],array[right]);
	}

	for(int i=1;i<=w;i++){
		printf("%d\n",array[i]);
	}

	// return 0;
}