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>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>
#include <sstream>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int W, N;
	vector<int> vec(40, 0);
	REP(i, 40) {
		vec[i] = i;
	}

	cin >> W >> N;
	REP(i, N) {
		int A, B;
		char C;
		cin >> A >> C >> B;
		swap(vec[A], vec[B]);
	}

	REP2(i, 1, W + 1) {
		cout << vec[i] << endl;
	}
	return 0;
}

C++: 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("%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 <iostream>
#include <stdio.h>
using namespace std ;

int w,n ;
int x,y ;

char otaku ;

int LenLine[31] ;

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

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

	for( int i = 0 ; i < n ; i ++ )
	{
		cin >> x >> otaku >> y ;

		swap( LenLine[x] , LenLine[y] ) ;
	}

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

	return 0 ;
}

C++: #define _CRT_SECURE_NO_WARNINGS 1

#include <cstdio>

using namespace std;

int main()
{
	int W, N, A[31], B[31], C[31];

	cin >> W >> N;

	for (int i = 1; i <= N; i++)
	{
		scanf("%d,%d", &(A[i]), &(B[i]));
	}

	for (int i = 1; i <= W; i++)
	{
		int t = i;

		for (int j = 1; j <= N; j++)
		{
			if (A[j] == t)
			{
				t = B[j];
			}
			else if (B[j] == t)
			{
				t = A[j];
			}
		}

		C[t] = i;
	}

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

	return 0;
}

C++: #include<cstdio>

int DP[31];
int w,n;


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

C++: #include<iostream>

int main(){
	int w,n,i,a,b,d,f,e[31];
	char c;

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

	for(i=1;i<=w;i++){
	e[i]=i;
	}
	for(i=0;i<n;i++){
		std::cin>>a>>c>>b;
		d=e[a];
		e[a]=e[b];
		e[b]=d;
	}

	for(i=1;i<=w;i++){
		std::cout<<e[i]<<std::endl;
	}
	return 0;
}

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

int main(){
	int n, m;
	cin >> n >> m;
	int a[n];
	for(int i = 0; i < n; i++){
		a[i] = i+1;
	}
	for(int i = 0; i < m; i++){
		stringstream ss1, ss2;
		string str;
		int p, q;
		cin >> str;
		ss1 << str[0];
		ss2 << str[2];
		ss1 >> p;
		ss2 >> q;
		swap(a[p-1],a[q-1]);
	}
	for(int i = 0; i < n; i++){
		cout << a[i] << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <sstream>
using namespace std;
int main() {
  int w;
  while (cin >> w) {
    vector<int> vec;
    vec.resize(w);
    // default
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n;
    cin >> n;
    cin.ignore(INT_MAX, '\n');
    for (int i = 0; i < n; ++i) {
      string str, tmp_a, tmp_b;
      int a, b;
      getline(cin, str);
      istringstream iss(str);
      getline(iss, tmp_a, ',');
      getline(iss, tmp_b, ',');
      a = stoi(tmp_a) - 1;
      b = stoi(tmp_b) - 1;
      int tmp = vec[a];
      vec[a] = vec[b];
      vec[b] = tmp;
    }
    for (int i = 0; i < vec.size(); ++i) {
      cout << vec[i] << endl;
    }
  } // while loop out
  return 0;
}

C++: #include<iostream>

using namespace std;

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

C++: #include <iostream>

using namespace std;

#define MAX_N (30)

void swap(int *a, int *b)
{
    int tmp;
    
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int main()
{
    int w;  // 縦線
    int n;  // 横線
    int a, b;
    char c;
    int amida[MAX_N];
    
    cin >> w;
    for (int i = 0; i < w; i++){
        amida[i] = i + 1;
    }
    
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a >> c >> b;
        swap(&amida[a - 1], &amida[b - 1]);
    }
    
    for (int i = 0; i < w; i++){
        cout << amida[i] << endl;
    }
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
 
int main(){
int w,n,a,b,tmp;
char dummy;                //w:縦線 n:横線　それぞれの本数
 
cin >> w >> n;
 
int line[w];
for(int i=0;i<w;i++){
        line[i] = i + 1;
        }
 
 
 
while(cin >> a >>dummy >> b){
        tmp = line[a-1];
        line[a-1] = line[b-1];
        line[b-1] = tmp;
        }
 
for(int j=0;j<w;j++){
        cout << line[j] << endl;
        }
 
 
 
 
return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	int a, b, v, h, tmp;
	char x;
	cin>>v;
	cin>>h;

	int num[v];
	//initialize array
	for(int i=0; i<v; i++){ num[i] = i+1; }
	
	for(int i=0; i<h; i++){
		cin>>a>>x>>b;
		swap(num[a-1], num[b-1]);
	}
	for(int i=0; i<v; i++) cout<<num[i]<<endl;
	return 0;
}

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

int main(){

int w, n;
int num[30]={0};
int a, b;

for(int i=0; i<w; i++)
num[i]=i+1;

cin>>w;
cin>>n;

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

cin>>a,b;

int tmp=num[a];
num[a]=num[b];
num[b]=tmp;


}


for(int i=0; i<w; i++)
cout<<num[i]<<"\n";

return 0;

}