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

C++: #include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
	int widthCount = 0, heightCount = 0;
	string tmp;

	cin >> widthCount >> heightCount;

	vector<int> width(widthCount);
	for(int i = 0; i < widthCount; i++){
		width[i] = i + 1;
	}
	
	pair<int,int> height;
	/*height.first = vector<int>(heightCount,0);
	height.second = vector<int>(heightCount,0);*/

	char *a = new char[4];
	char *tp;

	for(int i = 0; i < heightCount; i++){
		cin >> tmp;
		
		strcpy(a,tmp.c_str());
		
		tp = strtok(a,",");
		height.first = atoi(tp);
		tp = strtok(NULL,",");
		height.second = atoi(tp);

		swap(width[height.first - 1],width[height.second - 1]);

	}

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

	return 0;
}

C++: include<iostream>
using namespace std;
int main(){
    int w,n,tmp;
    cin>>w>>n;
    int a[w];
    string s;
    for(int i=0;i<w;i++) a[i]=i+1;
    for(int i=0;i<n;i++){
        cin>>s;
        int x=s[0]-(int)'1',y=s[2]-(int)'1';
        tmp=a[x];
        a[x]=a[y];
        a[y]=tmp;
    }
    for(int i=0;i<w;i++) cout<<a[i]<<endl;
    return 0;
}

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

using namespace std;
void lots(int len,int a,int b,int array[]){
    int buffer[5];
    for(int i = 0;i < len; i++){
        if(i == a-1){
            buffer[i] = array[b-1];
        }
        else if(i == b-1){
            buffer[i] = array[a-1];
        }
        else{
            buffer[i] = array[i];
        }
    }
    for(int i = 0; i < len; i++){
        array[i] = buffer[i];
    }

}

int main(){
    int len,duration,a,b;
    cin >> len;
    cin >> duration;
    int array[len];
    for(int i = 0; i < len; i++){
        array[i] = i+1;
    }
    for(int i = 0; i < duration; i++){
        scanf("%d,%d",&a,&b);
        lots(len,a,b,array);
    }
    for(int i = 0; i < len; i++){
        cout << array[i] << endl;
    }
}

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

using namespace std;
typedef pair<int, int> P;

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

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

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

int main(){

	using namespace std;

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