Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func swap(ints []int, i, j int) {
	ints[i], ints[j] = ints[j], ints[i]
}

func main() {
	w := nextInt()
	// println(w)
	nums := make([]int, w)
	for i := range nums {
		nums[i] = i+1
	}
	n := nextInt()
	// println(n)
	for i := 0; i < n; i++ {
		info := nextString()
		// println(info)
		infos := strings.Split(info, ",")
		a, _ := strconv.Atoi(infos[0])
		b, _ := strconv.Atoi(infos[1])
		swap(nums, a-1, b-1)
	}
	for _, v := range nums {
		fmt.Println(v)
	}
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
typedef pair<int,int> p;

int main()
{
	int w,n; cin>>w>>n;
	int ans[w];
	p sticks[n];
	char tmp;
	for(int i=0;i<n;i++)
	{
		cin>>sticks[i].first>>tmp>>sticks[i].second;
	}


	for(int i=0;i<w;i++)
	{
		int now=i+1;
		for(int j=0;j<n;j++)
		{
			if(sticks[j].first==now) now=sticks[j].second;
			else if(sticks[j].second==now) now=sticks[j].first;
		}
		ans[now-1]=i+1;
	}
	for(int i=0;i<w;i++) cout<<ans[i]<<endl;
	return 0;
}

C++: #include<stdio.h>

int w,n;
int a[31];
int x,y;
int k;

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

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

int main(){
vector<int>v;
int w,n;
int a,b;
char m;
cin>>w>>n;
for(int i=0;i<w;i++){
	v.push_back(i+1);
	}
	
	for(int i=0;i<n;i++){
cin>>a>>m>>b;
		swap(v[a],v[b]);
		}
		
		for(int i=0;i<w;i++){
			cout<<v[i]<<endl;
			}
			
		return 0;
		
		}

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

#define ll (long lon
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)

using namespace std;

int main (void){
    
    int tate,bnumber;
    int bridge[31][2] = {0};
    int answer[31] = {0};
    bool roopjudge = true;
    int temp = 0;
    int tempnumber = 0;
    int i,j,k,l;
    
    cin >> tate >> bnumber;
    for(i = 0;i< bnumber;i++)
        scanf("%d%*c%d",&bridge[i][0],&bridge[i][1]);
    /*
    REP(i, bnumber)
    cout << bridge[i][0] << ","<< bridge[i][1] << endl;
    */
    
    for(i = 1; i<=tate; i++)
    {
        temp = i;
        for(k = 0; k<bnumber;k++)
        {
            if(temp == bridge[k][0])
                temp = bridge[k][1];
            else if(temp == bridge[k][1])
                temp = bridge[k][0];
        }
        answer[temp] = i;
    }
    
    REP(i,tate)
    cout << answer[i+1] << endl;
    return 0;
    
}

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

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

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main(void)
{
    int w, n;
    cin >> w >> n;
    int m[w];
    for (int i = 0; i < w; i++)
    {
        m[i] = i;
    }
    for (int i = 0; i < n; i++)
    {
        int a, b;
        scanf("%d,%d", &a, &b);
        int t = m[a - 1];
        m[a - 1] = m[b - 1];
        m[b - 1] = t;
    }
    for (int i = 0; i < w; i++)
    {
        cout << m[i] + 1 << endl;
    }
    return 0;
}

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

using namespace std;

int amida[31][31] = { 0 };

int main(){

    int W, n;

    cin >> W;
    for (int vertical = 1; vertical <= W; vertical++){
        amida[vertical][0] = vertical;
    }

    cin >> n;
    for (int horizonal = 1; horizonal <= n; horizonal++){
        int a, b;
        scanf("%d,%d", &a, &b);

        for (int i = 1; i <= W; i++){
            if (i == a){
                amida[i][horizonal] = amida[b][horizonal - 1];
            }
            else if (i==b)
            {
                amida[i][horizonal] = amida[a][horizonal - 1];
            }
            else
            {
                amida[i][horizonal] = amida[i][horizonal - 1];
            }
        }
    }

    for (int i = 1; i <= W;i++){
        cout << amida[i][n] << endl;
    }

    return 0;
}

C++: #include<stdio.h>

int main(void){
	int ans[50],temp;
	int a,b,w,n;

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

C++: #include <iostream>
#include<cstdio>
using namespace std;
int main (){
	int w,N,d[30],sub;
	int a,b;

	cin>>w>>N;
	for(int j=1;j<=w;j++){
		d[j]=j;
	}
	for(int i=0;i<N;i++){
        scanf("%d,%d",&a,&b);
		sub=d[b];
		d[b]=c[a];
		c[a]=sub;
	}
	for(int k=1;k<=w;k++){
	cout<<d[k]<<endl;
	}

	return 0;
}

C++: #include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int w, n;
vector <pair <int, int> > vp;

int main(){
    cin >> w >> n;
    rep(i, n){
        int va, ri;
        scanf("%d, %d", &va, &ri);
        vp.push_back(make_pair(va, ri)); 
    }
    vi ans;
    rep(i, w)ans.push_back(i + 1);
    rep(i, w){
        int out = i + 1;
        rep(j, vp.size()){
            if(out == vp[j].first)out = vp[j].second;
            else if(out == vp[j].second)out = vp[j].first;
        }
        ans[out - 1] = i + 1;
    }
    rep(i, w)cout << ans[i] << endl;
}

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

int main(){
   int W,n,i,z,*num;
   int a[30],b[30];
   char s;
   cin>>W>>n;
   
   num = new int[W];
   for(i=0;i<W;i++) num[i] = i+1;
   
   for(i=0;i<n;i++){
      cin>>a[i]>>s>>b[i];
   }
   for(i=0;i<n;i++){
      z = num[a[i]-1];
      num[a[i]-1] = num[b[i]-1];
      num[b[i]-1] = z;
   }
   for(i=0;i<W;i++){
      printf("%d\n",num[i]);
   }
   delete[] num;
   return 0;
}

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

int main(){
	int w,n,wnum[30];
	for(int i = 0; i < 30; i++){
		wnum[i] = i;
	}
	cin >> w >> n;
	for(int i = 0; i < n; i++){
		int a,b;
		char comma;
		cin >> a >> comma >> b;
		swap(wnum[a],wnum[b]);
	}
	for(int i = 1; i <= w; i++){
		cout << wnum[i] << endl;
	}
	return 0;
}

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

int main(){
	int w, line[100], n, a, b, c;
	char x;

	cin >> w >> n;
	for (int i = 0; i < w; i++){
		line[i] = i + 1;
	}

	for (int i = 0; i < n; i++){
		cin >> a >> x >> b;
		c = line[a-1];
		line[a-1] = line[b-1];
		line[b-1] = c;
	}

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

	return 0;
}