Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)

	w := nextInt()
	n := nextInt()

	numbers := make([]int, w+1)
	for i := 1; i <= w; i++ {
		numbers[i] = i
	}

	for i := 0; i < n; i++ {
		line := nextString()
		words := strings.Split(line, ",")
		a, _ := strconv.Atoi(words[0])
		b, _ := strconv.Atoi(words[1])

		numbers[a], numbers[b] = numbers[b], numbers[a]
	}

	for i := 1; i <= w; i++ {
		fmt.Println(numbers[i])
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int w,n;

int main(){
    cin >> w >> n;
    vector<int> a(n),b(n);
    rep(i,n) scanf("%d,%d",&a[i],&b[i]),a[i]--,b[i]--;

    vector<int> number(w);
    iota(number.begin(),number.end(),1);
    rep(i,n) swap(number[a[i]],number[b[i]]);

    rep(i,w) cout << number[i] << endl;
}

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


int main(){
	int stick[40];
	int n,q;
	string pair;
	cin>>n;
	for(int i=0;i<n;i++){
		stick[i]=i+1;
	}
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>pair;
		swap(stick[pair[0]-'0'-1],stick[pair[2]-'0'-1]);
	}
	for(int i=0;i<n;i++){
		cout<<stick[i]<<endl;
	}
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main() {
  int w, n, a[30], b[30], c[30];
  cin >> w;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d,%d", &a[i], &b[i]);
    a[i]--;
    b[i]--;  
  }
  for (int i = 0; i < w; i++) {
    c[i] = i;
  }
  for (int i = 0; i < n; i++) {
    int d = a[i];
    int e = b[i];
    swap (c[d], c[e]);
  }
  for (int i = 0; i < w; i++) {
    cout << c[i] + 1 << endl;
  }
}

C++: #include <bits/stdc++.h>
#include <vector>
using namespace std;
int a[100000], w, n, x, y, h, p;
string o;
int main(){
	cin >> w >> n;
	for(int i = 1; i <= w; i++){
		a[i] = i;
	}
	for(int i = 1; i <= n; i++){
		x = 0;
		y = 0;
		cin >> o;
		p = o.find(',');
		for(int i = 0; i < p; i++){
			x *= 10;
			x += (int)o[i] - '0';
		}
		for(int i = p+1; i < o.length(); i++){
			y *= 10;
			y += (int)o[i] - '0';
		}
		h = a[y];
		a[y] = a[x];
		a[x] = h;
	}
	for(int i = 1; i <= w; i++){
		cout << a[i] << "\n";
	}
	return 0;
}

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

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

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

int main(){
	int w,n,i,a,b,d,f,e[31];
	char c;

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

	for(i=1;i<=w;i++){
	e[i]=i;
	}
	for(i=0;i<n;i++){
		std::cin>>a>>c>>b;
		d=e[a];
		e[a]=e[b];
		e[b]=d;
	}

	for(i=1;i<=w;i++){
		std::cout<<e[i]<<std::endl;
	}
	return 0;
}

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

int main(){
	int w[31]={0};
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){//1ツ氾板つゥツづァツ棒ツづ個青板づ慊づ渉可甘コツ可サ
		w[i-1]=i;
	}
	int a,b,t,ww;
	cin>>ww;
	for(int i=1;i<=ww;i++){
	cin>>a>>b;
	t=w[b];
	w[b]=w[a];
	w[a]=t;
	}
	for(int i=1;i<=n;i++){
		cout<<w[i-1]<<endl;
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int w,n;
	int d[100],e[100];
	int a[100];
	char c;
	cin>>w>>n;
	for(int i=0;i<n;i++)
		cin>>d[i]>>c>>e[i];
	for(int i=1;i<=w;i++)
		a[i]=i;
	for(int j=0;j<n;j++){
		int tmp=a[d[j]];
		a[d[j]]=a[e[j]];
		a[e[j]]=tmp;
	}
	for(int i=1;i<=w;i++)
		cout<<a[i]<<endl;
	return 0;
}

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

#define swap(a,b) a^=b^=a^=b

using namespace std;


int main(){
    
    int w,n,a,b;
    cin >> w >> n;
    vector<int> ans;
    for(int i=0;i<=w;i++){
        ans.push_back(i);
    }

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

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

int main() {
	ios_base::sync_with_stdio( false );

	int w, n;
	cin >> w >> n;

	vector<pair<int, int>> hl( n );

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

		hl[i] = { a, b };
	}

	vector<int> vl( w+1 );

	for( int i = 1; i <= w; ++i ) {
		int x = i;

		for( int j = 0; j < n; ++j ) {
			if( x == hl[j].first ) {
				x = hl[j].second;
			}
			else if( x == hl[j].second ) {
				x = hl[j].first;
			}
		}

		vl[x] = i;
	}

	for( int i = 1; i <= w; ++i ) {
		cout << vl[i] << '\n';
	}
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	int n , w , i , j , a , b;
	int number[40] ;
	cin >> w ;
	cin >> n;
	for( i=1 ; i<=n ; i++ ){
		scanf( "%d,%d" , &a , &b );
		int x = number[a];
		number[a] = number[b];
		number[b] = x ;
	}
	for( i=1 ; i<=w ; i++ )
		cout << number[i] << endl;
}

C++: 
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int w;
	int amida[31];
	int n;
	char aaa;
	cin >> w >> n;
	int a, b, keep;
	for (int i = 1; i <= w; i++) {
		amida[i] = i;
	}
	for (int i = 0; i < n; i++) {
		cin >> a >>aaa>> b;
		keep = amida[a];
		amida[a] = amida[b];
		amida[b] = keep;
	}
	for (int i = 1; i <= w; i++) {
		cout << amida[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include<cstdio>
using namespace std;
int main (){
	int w,N,d[30],c[30];
	int a,b;

	cin>>w>>N;
	for(int j=1;j<=w;j++){
		d[j]=j;
		c[j]=d[j];
	}
	for(int i=0;i<N;i++){
        scanf("%d,%d",&a,&b);
		d[a]=d[b];
		d[b]=c[a];
		c[a]=d[a];
	}
	for(int k=1;k<=w;k++){
	cout<<d[k]<<endl;
	}

	return 0;
}

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

int main()
{
  int w,n;
  int c[50]={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]);
  }
}