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 <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<int> bar;
    int n, w;
    char sp;
    int a[2];
    cin >> w;
    for(int c =1; c <= w; c++)
        bar.push_back(c);
    cin >> n;
    for(int c =0; c < n; c++)
    {
        cin >> a[0] >> sp  >> a[1];
        swap(bar[a[0] -1],bar[a[1] -1]);
    }
    for(int c=0; c < w; c++)
        cout << bar[c] << endl;
    return EXIT_SUCCESS;
}

C++: #include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#define INF 100000000
using namespace std;

int main(){
  int w,n;
  while(cin >> w >> n){
    int amida[31][31][31];
    for(int i=0; i<31; i++)
    for(int j=0; j<31; j++)
    for(int k=0; k<31; k++)
      amida[i][j][k] = 0;

    for(int i = 1 ; i <= n ; i++ ){
      int a,b;
      char ch;
      cin >> a >>ch>> b;
      amida[i][a][b]=amida[i][b][a]=1;
    }

    int from;
    for(int i = 1; i <= w ; i++ ){
      from = i;
      for(int depth = w ; depth >= 1 ; depth-- ){

	for(int to = 1 ; to <= w ; to++ ){
	  if(amida[depth][from][to] == 1){
	    from = to;
	    break;
	  }
	}

      }
      cout << from << endl;
    }

  }
  return 0;
}

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

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

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int w,n;
	cin>>w>>n;
	int c[31];
	for(int i=1;i<=w;i++)c[i]=i;
	for(int i=1;i<=n;i++){
		int a,b;
		scanf_s("%d,%d",&a,&b);
		swap(c[a],c[b]);
	}
	for(int i=1;i<=w;i++)cout<<c[i]<<endl;
}

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

using namespace std;

int main(){
    int w,n;
    int i,j;
    char c;
    cin >> w;
    cin >> n;
    vector<pair<int,int> > yokos(n+1);
    vector<int> result(w);
    for(i=0;i<n;++i){
        cin >> yokos[i].first >> c >> yokos[i].second;
    }
    for(i=1;i<=w;++i){
        int current = i;
        for(j=0;j<n;++j){
            if(yokos[j].first == current)
                current = yokos[j].second;
            else if(yokos[j].second == current)
                current = yokos[j].first;
        }
        result[current-1] = i;
    }
    for(i=0;i<w;++i){
        cout << result[i] << endl;
    }

    return 0;
}

C++: #include<iostream>

using namespace std;

int main() {
	int a,b;
	char c;
	cin >> a >> b;
	int x[a];
	int m,n,p;
	for(int i = 0;i<a;i++){
		x[i] = i+1;
	}

	for(int j = 0;j<b;j++){
		cin >> n >> c >> m;
		m--;
		n--;
		p = x[m];
		x[m] = x[n];
		x[n] = p;
	}
	for(int k = 0;k<a;k++){
		cout << x[k] << endl;
	}


	return 0;
}

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

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

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

int main() {
  int w,n;
  cin >>w >> n;
  vector <int> tate(w);

  for(int i=0;i<w;i++){// 配列tateに順に1-wを入力
    tate.at(i)=i+1;
  }
  
  while (n--) {
		int a, b;
		scanf("%d,%d", &a, &b);
		a--; b--;
		swap(tate.at(a), tate.at(b));
	}

    for(int i=0;i<w;i++){// 配列tateを左から順に出力
    cout << tate.at(i)<<endl;
  }
	return 0;
}

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>
using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

typedef pair<int, int> P;

int dp[60];

int main()
{
	int w(0),n(0);
	REP(i, 60){
		dp[i] = i;
	}
	cin >> n >> w;
	REP(i, w){
		int a, b;
		char c;
		scanf_s("%d,%d", &a,&b);
		swap(dp[a], dp[b]);
	}
	REP(i, n){
		cout << dp[i+1] << endl;
	}
}

C++: #include<stdio.h>
using namespace std;
const int MAX = 100;
int main() {
	int W, N;
	int t[MAX];

	cin >> W >> N;
	for (int i = 0; i < W; i++) {
		t[i] = i;
	}
	for (int i = 0; i < N; i++) {
		int a, b;
		scanf("%d,%d", &a, &b); a--; b--;
		swap(t[a], t[b]);
	}
	for (int i = 0; i < W; i++) {
		printf("%d\n", t[i] + 1);
	}
	return 0;
}

C++: #include<stdio.h>

int main(){
int tate,yoko,bou[30][2],j,x,kekka[]={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},i=0;
scanf("%d %d",&tate,&yoko);
for(j=0;j<yoko;j++){
scanf("%d %d",&bou[j][1],&bou[j][2]);
}
for(i=1;i<tate+1;i++){
x=i;
for(j=0;j<yoko;j++){
if(bou[j][1]==x){
x=bou[j][2];
}
else if(bou[j][2]==x){
x=bou[j][1];
}
}
kekka[x-1]=i;
}
for(j=0;j<tate;j++){
printf("%d\n",kekka[j]);
}
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 1000000001
#define EPS 1.0e-6

using namespace std;

typedef long long ll;

int w, n;
int a[35];

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

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

	int ai, bi;
	for (int i = 0; i < n; i++) {
		scanf("%d,%d", &ai, &bi);
		ai--; bi--;
		swap(a[ai], a[bi]);
	}
	for (int i = 0; i < w; i++) {
		cout << a[i] + 1 << endl;
	}


	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

PII a[35];
signed main(void)
{
  int w, n;
  cin >> w >> n;
  REP(i, n) {
    int x, y;
    cin >> x; cin.ignore(); cin >> y;
    a[i] = MP(x, y);
  }
  int ans[50];
  REP(i, w) {
    int now = i+1;
    REP(j, n) {
      if(now == a[j].first) now = a[j].second;
      else if(now == a[j].second) now = a[j].first;
    }
    ans[now] = i+1;
  }
  FOR(i, 1, w+1) cout << ans[i] << endl;
  return 0;
}

C++: #include <stdio.h>

void swap(int *a, int *b){
int c=*a;
*a=*b;
*b=c;
return;
}

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

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int w,n;
  cin>>w>>n;
  vi a(w);
  REP(i,w)a[i]=i+1;
  REP(i,n){
    int x,y;
    scanf("%d,%d",&x,&y);
    --x;--y;
    swap(a[x],a[y]);
  }
  REP(i,w)cout<<a[i]<<endl;
  return 0;
}