Go: package main

import "fmt"

func main() {
	var w, n int
	fmt.Scan(&w)
	numbers := make([]int, w)

	fmt.Scan(&n)

	intersect := make([][2]int, n)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scanf("%d,%d", &x, &y)
		intersect[i] = [2]int{x, y}
	}

	for i := 0; i < w; i++ {
		numbers[i] = i + 1
	}

	for _, v := range intersect {
		swap(numbers, v[0], v[1])
	}

	for _, v := range numbers {
		fmt.Println(v)
	}
}

func swap(arr []int, x, y int) {
	tmp := arr[x-1]
	arr[x-1] = arr[y-1]
	arr[y-1] = tmp
}

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

int set(int *arr, int n){
	for(int i = 1; i <= n; i++){
		arr[i] = i;
	}
}

int main(){
	int arr[50];
	int a, b;
	cin >> a >> b;
	set(arr, a);
	int x, y;
	for(int i = 0; i < b; i++){
		scanf("%d,%d", &x, &y);
		int temp = arr[x];
		arr[x] = arr[y];
		arr[y] = temp;
	}
	for(int i = 1; i <= a; i++){
		cout << arr[i] << endl;
	}
}

C++: #include<cstdio>
#include<algorithm>
int main(void){
    int i,w,n,a,b,*p;
    scanf("%d%d",&w,&n);
    p=new int[w];
    for(i=0;i<w;i++)p[i]=i+1;
    while(~scanf("%d,%d",&a,&b))std::swap(p[a-1],p[b-1]);
    for(i=0;i<w;i++) printf("%d\n",p[i]);
    return 0;
}

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

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

C++: #include <cstdio>

inline void swap(int array[], int a, int b){
	int c = array[a];
	array[a] = array[b];
	array[b] = c;
}

int main(){
	int array[50];
	int w,n,a,b;

	for(int i=0 ; i<50 ; i++){
		array[i] = i;
	}
	
	scanf("%d", &w);
	scanf("%d", &n);
	for(int i=0 ; i<n ; i++){
		scanf("%d,%d", &a, &b);
		swap( array , a , b );
	}
	for(int i=1 ; i<=w ; i++){
		printf("%d\n", array[i]);
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))



int main(){
	int n,q;
	cin >> n >> q;
	vector<int> A(n+1);
	FOR(i,1,n+1)A[i] = i;
	FOR(i,0,q){
		string s,x,y;
		cin >> s;
		bool k = false;
		for(char c:s){
			if(c==','){
				k = true;
				continue;
			}
			if(not k){
				x += c;
			}else{
				y += c;
			}
		}
		int a,b;
		a = stoi(x);
		b = stoi(y);
		swap(A[a],A[b]);
	}
	FOR(i,1,n+1){
		cout << A[i] << endl;
	}
}

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

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

using namespace std;


int main(){
    
    int w,n,a,b;
    cin >> w >> n;
    vector<int> ans;
    for(int i=0;i<=w;i++){
        ans.push_back(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;
    }
    
}

C++: #include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
typedef pair<int, int> P;

void solve()
{
	int w, n;
	cin >> w >> n;
	vector<P> vec(n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d,%d", &vec[i].first, &vec[i].second);
	}
	vector<int> pos(w);
	for(int i = 0; i < w; ++i)
	{
		int ans = i + 1;
		for(int j = 0; j < n; ++j)
		{
			if(vec[j].first == ans)
			{
				ans = vec[j].second;
			}
			else if(vec[j].second == ans)
			{
				ans = vec[j].first;
			}
		}
		pos[ans - 1] = i + 1;
	}
	for(int i = 0; i < w; ++i)
	{
		cout << pos[i] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

int main() {

	int place[31];
	int w, n;
	cin >> w >> n;
	for(int i = 1; i <= w; i++)
		place[i] = i;
	
	int a, b;
	char c;
	for(int i = 1; i <= n; i++){
		cin >> a >> c >> b;
		
		int temp = place[a];
		place[a] = place[b];
		place[b] = temp;
	}
	
	for(int i = 1; i <= w; i++)
		cout << place[i];
	
	return 0;
}

C++: #include <iostream>
using namespace std;
#include <stdio.h>
#define W 30
#define N 30

int main()
{
	int w, n;
	int a[W];
	int temp;
	int x, y;
	
	cin >> w;
	cin >> n;
	for (int i = 0; i < w; i++) {
		a[i] =i + 1;
	}
	
	for (int i = 0; i < n; i++) {
		scanf("%d, %d", &x, &y);
		temp = a[x - 1];
		a[x - 1] = a[y - 1];
		a[y - 1] =temp;
	}
	
	for (int i = 0; i < w; i++) {
		cout << a[i]  << "\n";
	}
	
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#define N 30
using namespace std;
int main(){
  int w,n,tmp;
  int lod[N]; int lis[N][3];
  while(cin >> n >> w){
  for(int i = 0;i<n;i++){
    lod[i] = i+1;
  }
 
  for(int i=0;i<w;i++){
    scanf("%d,%d",&lis[i][0],&lis[i][2]);
  }
  for(int i=0;i<w;i++){
    tmp = lod[lis[i][0]-1];
    lod[lis[i][0]-1] = lod[lis[i][2]-1];
    lod[lis[i][2]-1] = tmp;
  }
  for(int i=0;i<n;i++){
    cout << lod[i] << endl;
  }
  }
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){

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


	return 0;
}

C++: #include <stdio.h>
int RideBack[32];
void _swap(int left, int right) {int bk=RideBack[left];RideBack[left]=RideBack[right];RideBack[right]=bk;}
int main() {int N,W,i,j;scanf("%d %d",&W,&N);for (i=1;i<=W;RideBack[i]=i,i++);while (N--) {scanf("%d,%d",&i,&j);_swap(i,j);}for (i=1;i<=W;printf("%d\n",RideBack[i++]));return 0;}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long

int w, n;
int ban[35];
int main()
{
	REP(i, 35) ban[i] = i;
	cin >> w >> n;
	REP(i, n)
	{
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(ban[a], ban[b]);
	}
	FOR(i,1, w+1) cout << ban[i] << endl;
	return 0;
}

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

int main() {
    int w, n;
    cin >> w >> n;
    vector<int> v(w);
    iota(v.begin(), v.end(), 1);
    while(n--) {
        int an, bn;
        char c;
        cin >> an >> c >> bn;
        
        int a = v[an-1];
        int b = v[bn-1];
        v[an-1] = b;
        v[bn-1] = a;
    }
    for(int i=0; i<w; i++) {
        cout << v[i] << endl;
    }
    return 0;
}