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 <stdio.h>

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

C++: #include <iostream>
#include<algorithm>
#include<array>

using namespace std;

int W,N;

int main(){

	cin>>W>>N;
	array<pair<int,int>,30> p;
	char c;
	for(int i=0;i<N;i++){
		cin>>p[i].first>>c>>p[i].second;
		p[i].first--;
		p[i].second--;
	}
	int cc[30]={0};
	for(int j=0;j<W;j++){
		int co=j;
		for(int i=0;i<N;i++){
			
			if(p[i].first==co){
				co=p[i].second;
			}
			else if(p[i].second==co){
				co=p[i].first;
			}
		}
		cc[co]=j;
		//cout<<co<<endl;
	}
	for(int i=0;i<W;i++){
		cout<<cc[i]+1<<endl;
	}

	return 0;
}

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

int main()
{
	ifstream ifs("Text.txt");
	int w,wl[30],n,a,b,c;
	char ch;
	for(int i=0;i<30;i++){
		wl[i]=i;
	}
	cin>>w;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		cin>>ch;
		cin>>b;
		c=wl[a];
		wl[a]=wl[b];
		wl[b]=c;
	}
	for(int i=0;i<w;i++){
		cout<<wl[i+1]<<endl;
	}
}

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

int main(){
    int w,n;
    
    int line[35]={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,32,33,34,35};
    cin>>w>>n;
    for(int i=0; i<n; i++){
        int a,b;
       (cin>>a).ignore()>>b;
        swap(line[a],line[b]);
    }
    for(int i=0; i<w;i++){
        cout<<line[i]<<endl;
    }
        return 0;
}

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

int n;
int m;
int ans[1000];

int main() {
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    ans[i] = i;
  }

  scanf("%d", &m);
  for (int i=0; i<m; i++) {
    int a, b;
    scanf("%d,%d", &a, &b);
    swap(ans[a], ans[b]);
  }

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

C++: #include<stdio.h>
int main()
{
  int sen[31],y,i,k,hon,m,h;
  scanf("%d",&hon);
  for(i=1;i<=hon;i++)sen[i]=i;
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d,%d",&m,&h);
    y=sen[m];
    sen[m]=sen[h];
    sen[h]=y;
  }
  for(i=1;i<=hon;i++)printf("%d\n",sen[i]);
  return 0;
}

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

using namespace std;

void swap(int&, int&);

int main(){
  int w, n, a, b;
  char c;
  vector<int> x;

  cin >> w;
  cin >> n;

  for(int i=0; i<=w; ++i)
    x.push_back(i);

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

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

  return 0;
}

void swap(int& a, int& b){
  int c;
  c = a;
  a = b;
  b = c;
}

C++: // 0011.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
#include <typeinfo>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(ll a=0;a<t;a++)
int main()
{
	ll w, n;

	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> w >> n;
	ll a[32];
	roop(i, 32) {
		a[i] = i + 1;
	}
	roop(i, n) {
		int swap[2]; char kanma;
		cin >> swap[0] >> kanma >> swap[1];
		ll before = a[swap[0] - 1];
		a[swap[0] - 1] = a[swap[1] - 1];
		a[swap[1] - 1] = before;
	}
	roop(i, n) {
		cout << a[i] << endl;
	}
	return 0;
}

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

using namespace std;

int main(void) {


	//0011
	int Line[31], w=0, n=0, a, b, tmp;
	cin >> w;
	cin >> n;
	for (int i=0; i < 30; i++) {
		Line[i] = i;
	}
	for (int j = 0; j < n; j++) {
		scanf("%d,%d", &a, &b);
		tmp = Line[a];
		Line[a] = Line[b];
		Line[b] = tmp;
	}
	for (int k = 1; k <= w; k++) {
		cout << Line[k] << endl;
	}


	return 0;
}

C++: // 0011.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ld long double
int main()
{
	int w, n;

	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> w >> n;
	int a[32];
	for (int i = 0; i < 32; i++)
	{
		a[i] = i + 1;
	}
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		string d[2];
		for (int i = 0; i < s.length; i++) {
			if (s[i] == ',') { d[0] = s.substr(0, i); d[i] = s.substr(i + 1); break; }
		}
		int swap[2];
		for (int i = 0; i < 2; i++) {
			swap[i] = stoi(d[i]);
		}
		int before = a[swap[0] - 1];
		a[swap[0] - 1] = a[swap[1] - 1];
		a[swap[1] - 1] = before;
	}
	for (int i = 0; i < n; i++) {
		cout << a[i] << endl;
	}
	return 0;
}

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <complex>
using namespace std;
int main() {
	int w, n;
	cin >> w>> n;
	int temp[30];
	char s;
	int a[30], b[30];
	for (int i = 0;i < w;i++) {
		temp[i] = i + 1;
	}
	for (int i = 0;i < n;i++) {
		cin >> a[i] >> s >> b[i];
		int tempa;
			int tempb;
			tempa = temp[a[i]-1];
			tempb = temp[b[i]-1];
			temp[a[i]-1] = tempb;
			temp[b[i]-1] = tempa;
	}
	for (int i = 0;i < w;i++) {
		cout << temp[i] << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
    int w,n;
    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;       

        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;i++){
            cout << a[i] << endl;
        }
    }

    return 0;
}

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

int main(){
	int w,n;
	cin >> w >> n;
	int num[w + 1];
	for(int i = 1; i <= w; i++)num[i] = i;
	int a,b,temp;
	char c;
	while(cin >> a >> c >> b){
		temp = num[a];
		num[a] = num[b];
		num[b] = temp;
	}
	for(int i = 1; i <= w; i++)cout << num[i] << endl;
}