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<bits/stdc++.h>
using namespace std;
int w,n;
string stick[31];
string stick2[31];
string num[31]={"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"};
vector<pair<string,string> > pii;
int main(){
  cin>>w>>n;
  for(int i=1;i<=w;i++){
    if(i>=1&&i<=9)
      stick[i-1]=i+'0';
    else if(i>=10&&i<=99){
      stick[i-1]=(i/10)+'0';
      stick[i-1]+=(i%10)+'0';
    }
  }
  for(int i=0;i<n;i++){
    string a,b,c;
    cin>>a;
    for(int j=0;j<a.size();j++){
      if(a[j]==','){
	b=a.substr(0,j);
	c=a.substr(j+1,a.size()-b.size()-1);
      }
    }
    pii.push_back(make_pair(b,c));
  }
  for(int i=0;i<w;i++){
     for(int j=0;j<n;j++){
    if(stick[i]==pii[j].first)
      stick[i]=pii[j].second;
    else if(stick[i]==pii[j].second)
      stick[i]=pii[j].first;
     }
  }
  for(int i=0;i<w;i++){
    for(int j=0;j<w;j++){
      if(stick[i]==num[j]){
	if(i>=0&&i<=8)
	  stick2[j]=i+'1';
	else if(i>=9&&i<=99){
	  stick2[j]=((i+1)/10)+'0';
	  stick2[j]+=((i+1)%10)+'0';
	}
	break;
      }
    }
  }
  for(int i=0;i<w;i++)
    cout<<stick2[i]<<endl;
  return 0;
}

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

using namespace std;

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

	int kuji[n], a[n], b[n];
	for (int i = 1; i <= w; i++) kuji[i] = i;

	for (int i = 0; i < n; ++i) {
		scanf("%d, %d", &a[i], &b[i]);
		int tmp = kuji[a[i]];
		kuji[a[i]] = kuji[b[i]];
		kuji[b[i]] = tmp;
	}

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

C++: #include<iostream>

using namespace std;
 
int main() {
	
    int L[31];
    for(int i=0;i<30;i++)
	L[i]= i + 1;
	
    int a,b;
    cin >> a >> b;
    for(int i=0;i<b;i++){
    	
        int c,d;
        cin >> c >> d;
        
        int s = L[c-1];
        L[c-1] = L[d-1];
        L[d-1] = s;
        
    }
    for(int i=0;i<a;i++)
	cout << L[i] << "\n";
	
	return 0;
}

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


int main()
{
	int number[32];
	int index, pairnum;
	int a,b,tmp,i;
	cin >> index;
	cin >> pairnum;
	for( i = 0; i <32; i++ ) {
		number[i] = i;
	}

	for( i = 0; i < pairnum; i++ ) {
		scanf("%d,%d",&a,&b);
		tmp = number[a];
		number[a] = number[b];
		number[b]= tmp;
	}

	for( i = 1; i < index+1; i++ ) {
		printf("%d\n",number[i]);

	}

	return 0;
}

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

int main()
{
	int w;
	cin >> w;
	int n;
	cin >> n;
	vector<int> StartingPoint(w);
	for(int i = 0; i < w; i++){
		StartingPoint[i] = i+1;
	}
	for(int i = 0; i < n; i++){
		int HorizonalLineLeft;
		int HorizonalLineRight;
		char Dummy;
		cin >> HorizonalLineLeft >> Dummy >> HorizonalLineRight;
		swap(StartingPoint[HorizonalLineLeft-1], StartingPoint[HorizonalLineRight-1]);
	}
	for(int i = 0; i < w; i++){
		cout << StartingPoint[i] << endl;
	}
	return 0;
}

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

int main()
{
	int linecount = 0;
	std::scanf("%d", &linecount);

	std::vector<int> result(linecount);
	for (int i = 0; i < linecount; ++i) {
		result[i] = i + 1;
	}

	int swapcount = 0;
	std::scanf("%d", &swapcount);
	for (int i = 0; i < swapcount; ++i) {
		int swap1, swap2;
		if (std::scanf("%d,%d", &swap1, &swap2) == 2) {
			std::swap(result[swap1 - 1], result[swap2 - 1]);
		}
	}

	for (int i = 0; i < linecount; ++i) {
		std::printf("%d\n", result[i]);
	}

	return 0;
}

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

int main() {
	int w, n;
	scanf("%d%d", &w, &n);

	vector<int> result(w);
	iota(result.begin(), result.end(), 1);

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

	for(const auto &from : result) {
		cout << from << endl;
	}

	return EXIT_SUCCESS;
}

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

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

using namespace std;

int main(){
	int w; cin >> w;
	vector<int> amida;
	rep(i, w) amida.push_back(i + 1);
	int n; cin >> n;
	while(n --){
		int before, after;
		scanf("%d,%d", &before, &after);
		swap(amida[before - 1], amida[after - 1]);
	}
	rep(i, w) cout << amida[i] << endl;
	
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

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

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

#define add push_back
#define inf 2147000000

#define rep(i,n) for(int i=0;i<n;i++)
#define out(a) cout<<a<<endl;

using namespace std;

int main(void){
	int w,h;
	int y1[30],y2[30],t[31];
	string str;
	scanf("%d%d",&w,&h);
	rep(i,h){
		cin>>str;
		y1[i] = str[0]-48;
		y2[i] = str[2]-48;
	}
	rep(i,31)t[i]=i;
	
	rep(i,h){
		swap(t[y1[i]],t[y2[i]]);
	}
	
	rep(i,w)out(t[i+1]);
}

C++: #include<iostream>
using namespace std;
int main()
{
  int tate,yoko,lot[31];
  cin >> tate >> yoko;
  for(int i=1; i<=tate; i++)
    lot[i]=i;
  while(yoko-->0){
    int a,b,temp;
    char x;
    cin >> a >> x >> b;
    temp=lot[a];
    lot[a]=lot[b];
    lot[b]=temp;
  }
  for(int i=1; i<=tate; i++)
    cout << lot[i] << endl;
}

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

pair<int, int> p;
int a[31];

int main()
{
	int w, n, r;
	cin >> w >> n;
	for (int i = 1; i < w + 1; i++)
		a[i] = i;
	for (int i = 0; i < n; i++)
	{
		scanf_s("%d,%d", &p.first, &p.second);
		r = a[p.first];
		a[p.first] = a[p.second];
		a[p.second] = r;
	}
	for (int i = 1; i < w + 1; i++)
	{
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(void){
	int w,n;
	int a,b;
	int i;
	char ch;
	int m[31];
	cin>>w>>n;
	for(i=1;i<=w;i++)	m[i]=i;
	for(i=0;i<n;i++){
		cin>>a>>ch>>b;
		swap(m[a],m[b]);
	}
	for(i=1;i<=w;i++)	cout<<m[i]<<endl;
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_N=30;

int n,w;
int a[MAX_N],b[MAX_N];

char s[8];

int main(){
	scanf("%d",&w);
	scanf("%d",&n);
	REP(i,n){
		scanf("%s",s);
		int l=strlen(s);
		b[i]=-1;
		REP(j,l){
			if (s[j]!=','){
				if (b[i]==-1){
					a[i]*=10;
					a[i]+=s[j]-'0';
				}
				else{
					b[i]*=10;
					b[i]+=s[j]-'0';
				}
			}
			else{
				b[i]=0;
			}
		}
	}
	FOR(i,1,w+1){
		int c=i;
		for(int j=n-1;j>=0;j--){
			if (c==a[j]){
				c=b[j];
			}
			else if (c==b[j]){
				c=a[j];
			}
		}
		printf("%d\n",c);
	}
	return 0;
}

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

int main(){

	using namespace std;

	vector<int> array;
	int w,n;
	int a,b,i,j;
	
	scanf("%d %d\n",&w,&n);
	
	for(i=0;i<w;i++){
		array.push_back(i+1);
	}
	
	for(i=0;i<n;i++){
		scanf("%d,%d",&a,&b);
		array[a-1]=b;
		array[b-1]=a;
	}
	
	for(i=0;i<w;i++){
		cout << array[i] << endl;
	}
}