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>
using namespace std;

int main(){
  int w,n,i,j;
  int f,t;
  int value[31];
  for(i=1;i<31;i++){
    value[i]=i;
  }
  string str;
  cin >> w >> n;
  for(i=0;i<n;i++){
    cin >> str;
    if(str[1]==','){
      f = str[0] - '0';
      if(str.size()==3) t = str[2] - '0';
      else t = (str[2] - '0') * 10 + str[3] - '0';
    }else{
      f = (str[0] - '0') * 10 +  str[1] - '0';
      if(str.size()==4) t = str[3] - '0';
      else t = (str[3] - '0') * 10 + str[4] - '0';
    }
    int buf=value[f];
    value[f]=value[t];
    value[t]=buf;
  }
  for(i=1;i<w+1;i++){
    cout << value[i] << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
	int w, n;
	cin >> w;
	cin >> n;
	vector<int> l(w);
	rep(i, w)
	{
		l[i] = i+1;
	}
	
	rep(i, n)
	{
	    int a, b;
	    cin >> a;
	    cin.ignore();
	    cin >> b;
	    swap(l[a-1], l[b-1]);
	}
	
	rep(i, w)
	{
	    cout << l[i] << endl;
	}
}

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

using namespace std;

int main(void){
  int x,y,a,b,n[30];
  char s;

  cin >> y >> x;
  for(int i=0;i<y;i++)n[i]=i+1;

  for(int i=0;i<x;i++){
    cin >> a >> s >> b;
    swap(n[a-1],n[b-1]);
  }
  for(int i=0;i<y;i++)cout << n[i] << endl;

  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int stringTOlint(string s) {
	//string→lint
	lint Z = s.size();
	lint ret = 0;
	reverse(s);
	rep(i, Z) {
		ret += ((s[i] - '0') * pow(10, i));
	}
	return ret;
}

int main() {
	lint W, N;
	cin >> W >> N;
	vector<string>S(N);
	rep(i, N) {
		cin >> S[i];
	}
	bool flag = false;
	vector<string>A(N);
	vector<string>B(N);
	rep(i, N) {
		flag = false;
		rep(j, S[i].size()) {
			if (S[i][j] == ',') {
				flag = true;
			}
			else {
				if (flag) {
					B[i].push_back(S[i][j]);
				}
				else {
					A[i].push_back(S[i][j]);
				}
			}
		}
	}
	vector<lint>IA(N);
	vector<lint>IB(N);
	rep(i, N) {
		IA[i] = stringTOlint(A[i]);
		IB[i] = stringTOlint(B[i]);
	}
	lint now = 0;
	vector<lint>ANS;
	for (int i = 1; i <= W; i++) {
		now = i;
		rep(j, N) {
			if (IA[j] == now) {
				now = IB[j];
			}
			else if (IB[j] == now) {
				now = IA[j];
			}
		}
		ANS.push_back(now);
	}
	vector<IP>P(W);
	rep(i, W) {
		P[i].first = ANS[i];
		P[i].second = i + 1;
	}
	sort(P);
	rep(i, W) {
		cout << P[i].second << endl;
	}
}

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

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

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main()
{
    int m,n,a[30];
	cin >> m >> n;
	for(int i=0;i<m;i++)a[i]=i;
	for(int i=0;i<n;i++){
		string ss;
		cin >> ss;
		int x=ss[0]-'0';
		int y=ss[2]-'0';
		swap(a[x-1],a[y-1]);
	}
	for(int i=0;i<m;i++){
		printf("%d\n",a[i]+1);
	}
    return 0;
}

C++: #include<stdio.h>
 
int main(){
    int t[30];
    for(int i=0;i<30;i++)t[i]=i+1;
    int a,b;
    scanf("%d%d",&a,&b);
    for(int i=0;i<b;i++){
        int c,d;
        scanf("%d,%d",&c,&d);
        int s=t[c-1];
        t[c-1]=t[d-1];
        t[d-1]=s;
    }
    for(int i=0;i<a;i++)printf("%d\n",t[i]);
}

C++: #include <algorithm>
#include <iostream>
#include <limits>
#include <vector>
using namespace std;
int main() {
  int w, n;
  cin >> w >> n;
  vector<int> a(n), b(n), x(w);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cin.ignore(numeric_limits<unsigned>::max(), ',');
    cin >> b[i];
  }
  for (int i = 0; i < w; i++)
    x[i] = i + 1;
  for (int i = 0; i < n; i++)
    swap(x[a[i] - 1], x[b[i] - 1]);
  for (int i = 0; i < w; i++)
    cout << x[i] << endl;
}

C++: #include <stdio.h>
main() {
  int d[31];
  int buf,i,w,n,a,b;
  scanf("%d%d",&w,&n);
  for(i=1;i<=w;i++) {
    d[i]=i;
  }
  for(i=0;i<n;i++) {
    scanf("%d,%d",&a,&b);
    buf=d[a];d[a]=d[b];d[b]=buf;
  }
  for(i=1;i<=w;i++) printf("%d\n",d[i]);
}

C++: int main(){

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

	cin >> w;
	cin >> n;

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

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

		cin >> a >> b;

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


	}


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

	return 0;

}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

C++: #define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <vector>

class DrawLots
{
private:
	int w;					// 縦線の数
	int n;					// 横線の数
	int a, b;				// 入れ替える数値(実際は-1することによってインデックスになる)
	std::vector<int> W;		// int型の動的配列Wを作成
public:
	DrawLots();
	~DrawLots();
	void Print();
	void ExchengeElement();
};

int main()
{
	DrawLots DL = DrawLots();
	DL.ExchengeElement();
	DL.Print();
}

DrawLots::DrawLots()
{
	std::cin >> w;
	std::cin >> n;
	
	W = std::vector<int>(w);

	W.assign(w, 1);

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

DrawLots::~DrawLots()
{
}

void DrawLots::ExchengeElement()
{
	int tmp;
	for (int i = 0; i < n; i++)
	{
		
		scanf("%d,%d", &a, &b);

		tmp = W[a-1];
		W[a-1] = W[b-1];
		W[b-1] = tmp;

	}
}

void DrawLots::Print()
{
	for (unsigned int i = 0; i < W.size(); i++)
	{
		std::cout << W[i] << std::endl;
	}
}