Go: package main

import "fmt"

func main() {
	var w, n, a, b, i, te int
	var amida [31]int
	fmt.Scanf("%d", &w)
	fmt.Scanf("%d", &n)
	for i := 1; i <= w; i++ {
		amida[i] = i
	}
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d,%d", &a, &b)
		te = amida[a]
		amida[a] = amida[b]
		amida[b] = te
	}
	for i := i; i <= w; i++ {
		fmt.Printf("%d\n", amida[i])
	}
}

C++: #include <stdio.h>

int main (void)
{
	int w, i, n, m;
	scanf("%d", &w);
	
	int lot[w];
	for(i=0; i<w; i++)
	{
		lot[i]=i+1;
	}
	scanf("%d", &n);
	int lot_n[2];
	
	for(i=0; i<n; i++)
	{
		scanf("%d,%d", &lot_n[0], &lot_n[1]);
		m=lot[lot_n[0]-1];
		lot[lot_n[0]-1]=lot[lot_n[1]-1];
		lot[lot_n[1]-1]=m;
	}
	
	for(i=0; i<w; i++)
	{
		printf("%d\n", lot[i]);
	}
	return 0;
}

C++: #include<iostream>
int main(){int t[31],w=1,n,a,b;char c;for(;w<31;)t[w]=w++;for(std::cin>>w>>n;n--;t[a]^=t[b]^=t[a]^=t[b])std::cin>>a>>c>>b;for(n=1;n<w+1;)std::cout<<t[n++]<<'\n';}

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

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main(){
    int w,n;
    int np[31];
    scanf("%d",&w);
    scanf("%d",&n);
    int cbef,caft;
    for(int i=0;i<31;i++)
        np[i]=i;
    for(int i=0;i<n;i++){
        int sw;
        char gc;
        scanf("%d%c%d",&cbef,&gc,&caft);
        sw=np[cbef],np[cbef]=np[caft],np[caft]=sw;
    }
    for(int i=1;i<w+1;i++)
        printf("%d\n",np[i]);
    return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<math.h>

using namespace std;

typedef long long int lli;

int main() {
	int w, n;
	cin >> w >> n;
	vector<int> ar(w);
	vector<vector<int> > hor(n,vector<int>(2));
	for (int i = 0; i < w; i++) ar[i] += i+1;
	for (int j = 0; j < n;j++) {
		(cin >> hor[j][0]).ignore(1) >> hor[j][1];
		swap(ar[hor[j][0]-1], ar[hor[j][1]-1]);
	}
	for (int i = 0; i < w; i++) cout << ar[i] << endl;
	return 0;
}

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

int main()
{
	int w, n;
	int a[30], b[30];
	
	cin >> w >> n;

	for (int i = 0; i < n; i++) {
		char s;
		cin >> a[i] >> s >> b[i];
	}

	for (int i = 0; i < w; i++) {
		int g = i + 1;

		for (int j = n - 1; j >= 0; j--) {
			if (a[j] == g)
				g = b[j];
			else if (b[j] == g)
				g = a[j];
		}

		cout << g << endl;
	}

	return 0;
}

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

class Amidakuji{

public:
	int W;
	vector<int> array;//????´?1???????????????
	Amidakuji(int w);
	void Swap(int x,int y);
	void call();
};

//????????????????????????????????????
Amidakuji::Amidakuji(int w){

	for (int i = 0; i < w; i++){
		array.push_back(i+1);//[0,1,2,3,4]={1,2,3,4,5}
	}
	
	W = w;

}

void Amidakuji::Swap(int x,int y){

	//???????????£????????????array[]???????????????
	//int?????§???????????£????????§char???int?????????????????????-48;
	
	int q;
	q = array[x - 1];
	array[x-1] = array[y-1];
	array[y-1] = q;
	

}

void Amidakuji::call(){

	for (int i = 0; i<W; i++){
		cout << array[i] << endl;
	}

}

int main(){


	int w, n,loc,a,b;
	string text,str_a,str_b,str_v;

	while (cin >> w>>n){
		cin.ignore();
		//??????????????????????????§???????????????
		Amidakuji Amidakuji(w);
		for (int i = 0; i < n; i++){
			getline(cin, text);

			//????????¶?????§??????10,2??????????????¨??????{1,0,,,2}??????????????¢????????£?????????????????§??????????????????????????????????????????

			//?????????????????????????????????????????????????????§?????????????????£?????????????????\????????????????????£???
			loc=text.find(",", 0);
			str_a = text[0];
			for (int j = 1; j < loc; j++){
				str_v = text[j];
				str_a = str_a + str_v;

			}
			str_b = text[loc + 1];
			for (int j = loc + 2; j < (signed) text.length(); j++){
				str_v = text[j];
				str_b = str_b + str_v;
			}

			
			a = stoi(str_a);
			b = stoi(str_b);


			if (a != 0 && b != 0){
				//???????????????????????????swap???????????????
				Amidakuji.Swap(a, b);
				a = b = 0;
			}
		}
	
		//????????????
		Amidakuji.call();
	}

	return 0;
}

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

using namespace std;

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

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