Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	lines, _ := strconv.Atoi(sc.Text())
	l := make([]int, lines)
	for i := 0; i < lines; i++ {
		l[i] = i + 1
	}

	sc.Scan()
	rows, _ := strconv.Atoi(sc.Text())
	for i := 0; i < rows; i++ {
		sc.Scan()
		s := strings.Split(sc.Text(), ",")
		a, _ := strconv.Atoi(s[0])
		b, _ := strconv.Atoi(s[1])

		l[a-1], l[b-1] = l[b-1], l[a-1]
	}
	for _, j := range l {
		fmt.Println(j)
	}
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
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<=w; 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\n",c[i]);
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int d[30];

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int W, N;
	scanf("%lld%lld", &W, &N);
	rep(i, W) d[i] = i + 1;
	rep(i, N) {
		int a, b;
		scanf("%lld,%lld", &a, &b);
		a--; b--;
		swap(d[a], d[b]);
	}

	rep(i, W) cout << d[i] << endl;
	return 0;
}

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

using namespace std;

int cell[31];

int main() {
    int w, n, a, b;

    for (int i = 1; i <= 30; i++) {
        cell[i] = i;
    }

    cin >> w >> n;

    while (n--) {
        int a, b;
        scanf("%d,%d", &a, &b);
        swap(cell[a], cell[b]);
    }

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

    return 0;
}

C++: #include<stdio.h>

int main()
{
	int StrLen, LinkNum;
	int EndNum[50] = {0};
	int link[50][2];
	scanf("%d %d", &StrLen, &LinkNum);
	for (int i = 0; i < LinkNum; i++)
		scanf("%d,%d", &link[i][0], &link[i][1]);
	for (int i = 1; i <= StrLen; i++)
	{
		int posi = i;
		for (int j = 0; j < LinkNum; j++)
		{			
			if (link[j][0] == posi)
				posi = link[j][1];
			else if (link[j][1] == posi)
				posi = link[j][0];				
		}
		EndNum[posi-1] = i;
	}
	for (int i = 0; i < StrLen; i++)
		printf("%d\n", EndNum[i]);
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main(void) {
    int n, q; 
    scanf("%d\n%d", &n, &q);
    vector<int> arr(n);
    iota(arr.begin(), arr.end(), 1);
    while (q--) {
        int l, r;
        scanf("%d,%d", &l, &r);
        --l, --r;
        swap(arr[l], arr[r]);
    }
    for (int i = 0; i < n; i++) 
        printf("%d\n", arr[i]);
    return 0;
}

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

int main()
{
  int map[30][32];
  int x,y;
  int w,n;
  int tmp;

  cin >> w;
  cin >> n;
  for(int i=0;i<w;i++){
    for(int j=0;j<=n;j++)map[i][j] = i;
  }

  for(int i=1;i<=n;i++){
    scanf("%d,%d ",&x,&y);
    map[x-1][i] = y-1;
    map[y-1][i] = x-1;
  }

  for(int i=0;i<w;i++){
    tmp=i;
    for(int j=1;j<=n;j++)tmp = map[tmp][j];
    map[tmp][n+1] = i;
  }

  for(int i=0;i<w;i++)cout << map[i][n+1]+1 << endl;

  return 0;
}

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

int main() {
  int w, n;
  vector<int> l;
  cin >> w; cin >> n;
  for (int i = 0; i < w; i++) l.push_back(i + 1);
  for (int i = 0; i < n; i++) {
    int a, b; char comma;
    cin >> a >> comma >> b; a--; b--;
    int buf = l[a]; l[a] = l[b]; l[b] = buf;
  }
  for (int i = 0; i < w; i++) cout << l[i] << endl;
  return 0;
}

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

int main(){
	int ary[31];
	int w, n, a, b;
	for(int i=0; i < 31; i++){
		ary[i] = i;
	}
	cin >> w;
	cin >> n;
	for(int i=0; i < n; i++){
		scanf("%d,%d", &a, &b);

		swap(ary[a], ary[b]);
	}
	for(int i=1; i <= w; i++){
		cout << ary[i] << endl;
	}

}

C++: #include <iostream>
#include <set>
#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 <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)

int main(){
    int w, n;
    cin >> w >> n;
    vector<int> num(w, 0);
    int it = 1;
    for(int& k : num) k = it++;
    rep(i, n){
        int a, b;
        char c;
        cin >> a >> c >> b;
        a--; b--;
        swap(num[a], num[b]);
    }
    for(int k : num)
      cout << k << endl;
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    //cin.tie(0);
    //ios::sync_with_stdio(false);

    int w, n;
    int a, b;
    char ch;

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

    vector<int> v(w);

    int i;

    for (i = 1; i <= w; i++) v[i - 1] = i;

    while (n--) {
        scanf("%d%c%d", &a, &ch, &b);

        a--;
        b--;

        swap(v[a], v[b]);
    }

    for (i = 0; i < w; i++) printf("%d\n", v[i]);

    return 0;
}

C++: #include<stdio.h>

int main()
{
	int w,n,a,b,x,y;
	scanf("%d",&w);
	scanf("%d",&n);
	int m[30]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30};

	for(x=0;x<n;x++)
	{
		scanf("%d,%d",&a,&b);
		if(m[a-1]<=m[b-1])
		{
			y=m[b-1]-m[a-1];
			m[a-1]+=y;
			m[b-1]-=y;
		}
		else if(m[a-1]>m[b-1])
		{
			y=m[a-1]-m[b-1];
			m[b-1]+=y;
			m[a-1]-=y;
		}
	}

	for(x=0;x<w;x++)
	{
		printf("%d\n",m[x]);
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main() {
  int w, n;
  cin >> w >> n;
  vector<int> vec;
  vec.resize(w);
  for (int i = 0; i < vec.size(); ++i) {
    vec[i] = i + 1;
  }
  int a, b;
  for (int i = 0; i < n; ++i) {
    scanf("%d,%d", a, b);
    a -= 1;
    b -= 1;
    int tmp = vec[a];
    vec[a] = vec[b];
    vec[b] = tmp;
  }
  for (int i = 0; i < vec.size(); ++i) {
    cout << vec[i] << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int w, n;
	cin >> w >> n;
	int s[w];

	for(int i=0; i<w; i++){
		s[i] = i+1;
		while(n--){
		int a, b, c;
		cin >> a >> b;

		int tmp = s[a-1];
		s[a-1] = s[b-1];
		s[b-1] = tmp;
	}
	}

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