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 <cstdio>
#include <vector>
using namespace std;

int main() {
    int i, w, n;
    int a, b;
    int ami[40];

    cin >> w >> n;
    for (i=0; i<w; i++) ami[i] = i+1;
    for (i=0; i<n; i++) {
        scanf("%d,%d\n", &a, &b);
        swap(ami[a-1], ami[b-1]);
    }
    for (i=0; i<w; i++) cout << ami[i] << endl;
    return 0;
}

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

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

}

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

int main() {
    int w, n;
    cin >> w >> n;
    vector<int> v(w);
    for(int i=0; i<w; ++i) {
        v[i] = i+1;
    }
    for(int i=0; i<n; ++i) {
        int a, b;
        scanf("%d,%d", &a, &b);
        a--; b--;
        swap(v[a], v[b]);
    }
    for(auto x : v) {
        cout << x << endl;
    }
}

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

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

using namespace std;

int w, n;

struct bar {
	int a, b;
};

vector <bar> v;
int order[35];

int main() {
	scanf("%d", &w);
	scanf("%d", &n);
	
	for (int i=0; i<n; i++) {
		bar r;
		scanf("%d, %d", &r.a, &r.b);
		v.push_back(r);
	}
	
	for (int i=1; i<=w; i++) {
		int s = i;
		for (int j=0; j<n; j++) {
			if (v[j].a==s) s = v[j].b;
			else if (v[j].b==s) s = v[j].a;
		}
		order[s] = i;
	}
	
	for (int i=1; i<=w; i++) cout << order[i] << endl;
	
	return 0;
}

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

using namespace std;

int main() {
    int w, n, h[31][2], v[31], pos;
    cin >> w >> n;

    for (int i = 0; i < n; i++) {
        scanf("%d, %d", &h[i][0], &h[i][1]);
    }
    for (int i = 1; i <= w; i++) {
        pos = i;
        for (int j = 0; j < n; j++) {
            if (pos == h[j][0]) {
                pos = h[j][1];
            }
            else if (pos == h[j][1]) {
                pos = h[j][0];
            }
        }
        v[pos] = i;
    }
    for (int i = 1; i <= w; i++) {
        cout << v[i] << endl;
    }
    
    return 0;
}

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

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main(){
	int w, n, a, b;
	vi v;
	cin >> w >> n;
	FOR(i, 1, w+1){
		v.push_back(i);
	}
	REP(i,n){
		scanf("%d,%d",&a, &b);
		swap(v[a-1], v[b-1]);
	}
	REP(i, w){
		cout << v[i] << "\n";
	}
}

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

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

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

#define MAX 30
#define rep(i, a) for(int i = 0; i < (a); ++i)
#define rept(i, a, b) for(int i = (a); i <= (b); ++i)

int main(){
	int w, n;
	int num[MAX];
	int a, b;
	std::cin >> w >> n;
	rep(i, MAX)
		num[i] = i + 1;		
	rep(i, n){
		scanf("%d,%d", &a, &b);
		std::swap(num[a - 1], num[b - 1]);
	}
	rep(i, w)
		std::cout << num[i] << std::endl;
	return 0;
}

C++: #include<iostream>

using namespace std;
int data[40];
int main(){

	for(int i=0;i<40;i++)data[i]=i;
	int w;
	int n;
	cin>>w;
	cin>>n;
	for(int i=0;i<n;i++){
		char tmp[4];
		cin>>tmp;
		int a=tmp[0]-'0';
		int b=tmp[2]-'0';
		int t=data[a];
		data[a]=data[b];
		data[b]=t;
	}
	
	for(int i=1;i<=w;i++)cout<<data[i]<<endl;
}

C++: #include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
#define FOR(i, s, e) for(int i = s; i < e; ++i)
void getValues(string& s, int& a, int & b)
{
	string::size_type p = s.find(',');
	string sa = s.substr(0, p);
	string sb = s.substr(p + 1);
	a = atoi(sa.c_str());
	b = atoi(sb.c_str());
}

int main()
{
	int w, n, a, b;
	cin >> w >> n;
	int W[31] = {};
	FOR(i, 1, w + 1) W[i] = i;
	string line;
	while (n--){
		cin >> line;
		getValues(line, a, b);
		swap(W[a], W[b]);
	}
	FOR(i, 1, w + 1) cout << W[i] << "\n";
	return 0;
}

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

int main()
{
  int width,number;
  cin >> width >> number;
  int change[number][2];
  string str;
  for(int i=0; i<number; i++){
    scanf("%d,%d",&change[i][0],&change[i][1]);
  }
  int bou[width+1];
  for(int i=0; i<width+1; i++){
    bou[i] = i;
  }
  int temp;
  for(int i=0; i<number; i++){
    temp = bou[change[i][0]];
    bou[change[i][0]] = bou[change[i][1]];
    bou[change[i][1]] = temp;
  }

  for(int i=1; i<width+1; i++){
    cout << bou[i] << endl;
  }
  return 0;
}

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

#define swap(a,b) a^=b^=a^=b

using namespace std;

int main(){
    
    int w,n,a,b;
    cin >> w >> n;
    int *ans = new int(w+1);


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

    for(int i=0;i<n;i++){
        scanf("%d,%d",&a,&b);
        swap(ans[a],ans[b]);
    }
    for(int i=1;i<=w;i++){
        cout << ans[i] << endl;
    }
    delete ans;
    
}

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

int w, n, l[31];

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

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

	scanf("%d", &W);
	scanf("%d", &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;
}