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 <cstdlib>

using namespace std;

int main(){
	int VLineNum, HLineNum;
	cin >> VLineNum;
	cin >> HLineNum;

	int* Data = new int[VLineNum];//あみだくじNo.配列初期化
	for (int i = 0; i < VLineNum; ++i){
		Data[i] = i + 1;
	}

	int a, b, temp;//データロード&あみだくじ数値反転
	for (int i = 0; i < HLineNum; ++i){
		scanf("%d,%d", &a, &b);
		temp = Data[b-1];
		Data[b-1] = Data[a-1];
		Data[a-1] = temp;
	}

	for (int i = 0; i < VLineNum; ++i){//出力
		cout << Data[i] << endl;
	}

	delete [] Data;

	return 0;
}

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

int main()
{
  int w,n;
  int c[]={0};
  int a,b;
  //  int temp;

  scanf("%d",&w);
  scanf("%d",&n);

  for(int i=0; i<=n; i++){
    c[i]=i;
  }

  for(int i=0; i<n; i++){
    scanf("%d,%d", &a,&b);
    swap(c[a], c[b]);
  }

  for(int i=1; i<=w; i++){
    printf("%d",c[i]);
  }
}

C++: #include<algorithm>
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
  int lot[33]; // くじ
  int w,n,a,b;
  for(int i=1;i<=30;i++)lot[i] = i;
  cin >> w >> n;

  for(int i=0;i<n;i++){
    scanf("%d,%d",&a,&b);
    swap(lot[a],lot[b]);
  }

  for(int i=1;i<=w;i++){
    cout << lot[i] << endl;
  }
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int ans[31]={};
int a[31],b[31];

int main() {

	int w,n;
	cin>>w;
	cin>>n;
	char c=',';
	rep(i,n)cin>>a[i]>>c>>b[i];
	for(int i=1; i<w+1; i++){
		int x=i;
		rep(j,n){
			if(x==a[j])x=b[j];
			else if(x==b[j])x=a[j];
		}
		ans[x]=i;
	}
	rep(i,w)cout<<ans[i+1]<<endl;

	return 0;
}

C++: #include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  // ifstream cin("../test.txt");
  int w,n;
  int a[30],b[30],c[30];
  cin >> w >> n;
  for (int i = 0; i < w; i++) {
    c[i] = i+1;
  }
  char x;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> x >> b[i];
    // cout << a[i] << " " << b[i] << endl;
  }
  for (int i = 0; i < n; i++) {
    // swap(c[a[i]-1], c[b[i]-1]);
    int k = a[i] - 1;
    int j = b[i] - 1;
    int tmp = c[k];
    c[k] = c[j];
    c[j] = tmp;
  }
  for (int i = 0; i < w; i++) {
    cout << c[i] << endl;
  }
}

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


int main()
{
	int w, n, num[31];
	string s;
	cin >> w;
	fill(num, num + 31, 0);
	for (int i = 1; i < w + 1; i++){
		num[i] = i;
	}
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		string l, r;
		int commapos;

		//カンマの左
		for (int i = 0;; i++){
			if (s[i] == ','){
				commapos = i;
				break;
			}
			else{
				l += s[i];
			}
		}

		//カンマの右
		for (int i = commapos + 1; i < s.length(); i++){
			r += s[i];
		}
		int left = atoi(l.c_str());
		int right = atoi(r.c_str());
		int temp = num[left];
		num[left] = num[right];
		num[right] = temp;
	}
	for (int i = 1; i < w + 1; i++){
		cout << num[i] << endl;
	}
	return 0;
}

C++: #include <cstdio>
#define SWAP(a,b) {a+=b,b=a-b,a-=b;}

using namespace std;

int W[30];

int main()
{
	int w,n,ai,bi;
	scanf("%d",&w);
	for(int i=0;i<w;++i) W[i]=i+1;
	scanf("%d",&n);
	for(int i=0;i<n;++i) {
		scanf("%d,%d",&ai,&bi);
		SWAP(W[ai-1],W[bi-1]);
	}
	for(int i=0;i<w;++i) { printf("%d\n",W[i]); }
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (int) (1e9+7)
#define INF (int) 2e9

int main(){
    int w, n;
    cin >> w >> n;
    int ans[w+1];
    rep(i, w+1){
        ans[i] = i;
    }
    rep(i, n){
        int a, b;
        scanf("%d,%d", &a, &b);
        // cin >> a >> b;
        swap(ans[a], ans[b]);
    }
    for (int i = 1; i <= w; i++) {
        cout << ans[i] << endl;
    }
    
    // printf("%d\n", N);
    return 0;
}

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

using namespace std;

void Swap(vector<int>& v, int index1, int index2) {
    int tmp = v[index1];
    v[index1] = v[index2];
    v[index2] = tmp;
}


int main() {
    int w;
    cin >> w;

    vector<int> v(w);
    for(int i = 0; i < v.size(); ++i) {
        v[i] = i + 1;
    }
    
    int n;
    cin >> n;

    for(int i = 0, a, b; i < n; ++i) {
        cin >> a;
        cin.ignore();
        cin >> b;

        Swap(v, a - 1, b - 1);
    }

    for(auto x : v) {
        cout << x << '\n';
    }

    return 0;
}

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

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	int w, n;
	scanf("%d%d", &w, &n);

	vi line(w);
	rep(i, w) line[i] = i+1;
	rep(i, n){
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(line[a-1], line[b-1]);
	}

	rep(i, w) printf("%d\n", line[i]);

	return 0;
}

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

int main(){
	int w;
	while(cin>>w){
		vector<pair<int, int> > all;
		int n;
		cin>>n;
		for(int i=0; i<n; i++){
			int a, b;
			scanf("%d,%d", &a, &b);
			all.push_back(pair<int, int>(a, b));
		}
		reverse(all.begin(), all.end());
		for(int i=1; i<=w; i++){
			int ima = i;
			for(int j=0; j<n; j++){
				if(all[j].first == ima){
					ima = all[j].second;
				} else if(all[j].second == ima){
					ima = all[j].first;
				}
			}
			cout<<ima<<endl;
		}
	}
}

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

struct THorizonalLine
{
	int Left;
	int Right;
};

int main()
{
	int w;
	cin >> w;
	int n;
	cin >> n;
	vector<int> StartingPoint(w);
	for(int i = 0; i < w; i++){
		StartingPoint[i] = i+1;
	}
	for(int i = 0; i < n; i++){
		THorizonalLine HorizonalLine;
		scanf("%d,%d",&HorizonalLine.Left,&HorizonalLine.Right);
		swap(StartingPoint[HorizonalLine.Left-1], StartingPoint[HorizonalLine.Right-1]);
	}
	for(int i = 0; i < w; i++){
		cout << StartingPoint[i] << endl;
	}
	return 0;
}

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

int main() {
	int w, n;
	int a[30];
	cin >> w >> n;
	for (int i = 0;i < w;i++) {
		a[i] = i + 1;
	}
	for (int i = 0;i < n;i++) {
		int p, q;
		char s;
		cin >> p >> s >> q;
		swap(a[p - 1], a[q - 1]);
	}
	for (int i = 0;i < w;i++)cout << a[i] << endl;
}

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

int main()
{
	int w, n;
	int a, b;
	
	scanf("%d%d", &w, &n);

	vector<int> num(w + 1);

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

	for (int i = 0; i < n; i++){
		scanf("%d,%d", &a, &b);
		swap(num[a], num[b]);
	}

	for (int i = 1; i <= w; i++){
		printf("%d\n", num[i]);
	}

	return (0);
}