Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)

	w := nextInt()
	n := nextInt()

	numbers := make([]int, w+1)
	for i := 1; i <= w; i++ {
		numbers[i] = i
	}

	for i := 0; i < n; i++ {
		line := nextString()
		words := strings.Split(line, ",")
		a, _ := strconv.Atoi(words[0])
		b, _ := strconv.Atoi(words[1])

		numbers[a], numbers[b] = numbers[b], numbers[a]
	}

	for i := 1; i <= w; i++ {
		fmt.Println(numbers[i])
	}
}

C++: #include <iostream>

using namespace std;

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

C++: #include<stdio.h>
int main(void)
{
	int a,s,d,f,g[31],h,i,j;
	scanf("%d",&a);
	scanf("%d",&s);
	for(i=1;i<=a;i++){
		g[i]=i;
	}
	for(i=1;i<=s;i++){
		scanf("%d,%d",&d,&f);
		h=g[d];
		g[d]=g[f];
		g[f]=h;
	}
	for(i=1;i<=a;i++){
		printf("%d\n",g[i]);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int w,n,a,b,num[30];
	char ch;
	cin >> w >> n;
	for(int i=0;i<w;i++){
		num[i] = i+1;
	}
	for(int i=0;i<n;i++){
		cin >> a >> ch >> b;
		swap(num[a-1],num[b-1]);
	}
	for(int i=0;i<w;i++){
		cout << num[i] << endl;
	}
	return 0;
}

C++: #include<algorithm>
#include<iostream>
using namespace std;
int main(){
	int w,n;
	cin>>w>>n;
	int a[w],b[w];
	for(int i=0;i<n;i++){
		swap(a[n],b[n]);
	}
	for(int j=0;j<w;j++){
		cout<<a[j]<<endl<<b[j]<<endl;
	}
}

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

struct THorizonalLine
{
	int Left;
	int Right;
};

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++){
		THorizonalLine HorizonalLine;
		scanf("%d,%d",&HorizonalLine.Left,&HorizonalLine.Right);
		swap(StartingPoint[HorizonalLine.Left-1], StartingPoint[HorizonalLine.Right-1]);
	}
	for(int i = 0; i < w; i++){
		cout << StartingPoint[i] << endl;
	}
	return 0;
}

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

using namespace std;

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

	vector<int> s(w);
	for (int i = 1; i <= w; ++i)
		s[i] = i;

	while (n--)
	{
		int a, b;
		scanf("%d,%d", &a, &b);

		swap(s[a], s[b]);
	}

	for (int i = 1; i <= w; ++i)
		cout << s[i] << endl;

	return 0;
}

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

int main() {
	int w, n, a, b;

	cin >> w >> n;
	auto hlines = vector<int>(w);
	for (int i = 0; i < w; ++i) {
		hlines.at(i) = i + 1;
	}

	for (int i = 0; i < n; ++i) {
		cin >> a;
		cin.ignore();
		cin >> b;
		--a, --b;
		swap(hlines.at(a), hlines.at(b));
	}
	for (int const x : hlines) {
		cout << x << endl;
	}
	return 0;
}

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