Go: package main

import (
        "fmt"
)

const MAX_N = 31
var lines [MAX_N]int

func main() {
        var n, w int
        fmt.Scanf("%d", &n)
        fmt.Scanf("%d", &w)

        Init()
        var l, r int
        for {
                _, err := fmt.Scanf("%d,%d", &l, &r)
                if err != nil {
                        break
                }

                Swp(l, r)
        }

        for i := 1; i <= n; i++ {
                fmt.Printf("%d\n", lines[i])
        }
}

func Swp(l int, r int) {
        var s int
        s = lines[l]
        lines[l] = lines[r]
        lines[r] = s
}

func Init() {
        for i := 0; i < MAX_N; i++ {
                lines[i] = i
        }
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int n;
int w;
int line[30][2];
int perm[31];

int main() {
	cin >> n;
	cin >> w;
	for (int i = 0; i < w; i++) {
		char str[3];
		cin >> str;
		line[i][0] = str[0] - '0';
		line[i][1] = str[2] - '0';
	}

	for (int i = 1; i <= n; i++) {
		int pt = i;
		for (int j = 0; j < w; j++) {
			if (line[j][0] == pt) pt = line[j][1];
			else if (line[j][1] == pt) pt = line[j][0];
		}
		perm[pt] = i;
	}

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

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

C++: #include <stdio.h>

int main(){

	int w = 0, y = 0, i, t[30] = {},a=0,b=0;

	scanf("%d%d", &w, &y);

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

	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int w, n;
	cin >> w >> n;
	int s[w];

	for(int i=0; i<w; i++){
		s[i] = i+1;
		while(n--){
		int a, b, c;
		cin >> a >> b;

		int tmp = s[a-1];
		s[a-1] = s[b-1];
		s[b-1] = tmp;
	}

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

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main( void )
{
	int w, n;
	cin >> w >> n;
	vector <int> S(w);
	for ( int i = 0; i < w; i++ )
		S[i] = i+1;

	for ( int i = 0; i < n; i++ )
	{
		int a, b;
		char c;
		cin >> a >> c >> b;
		swap( S[a-1], S[b-1] );
	}

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

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    int w,n;
    int a[30]={-1};
    int j,k;
    int temp1;
    
    while(cin >> w){
        
        if(w==0)break;

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

        cin >> n;       

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

            cin >> j >> temp >> k;
            
            temp1=a[j-1];
            a[j-1]=a[k-1];
            a[k-1]=temp1;

        }

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

    return 0;
}

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;
}