Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func swap(ints []int, i, j int) {
	ints[i], ints[j] = ints[j], ints[i]
}

func main() {
	w := nextInt()
	// println(w)
	nums := make([]int, w)
	for i := range nums {
		nums[i] = i+1
	}
	n := nextInt()
	// println(n)
	for i := 0; i < n; i++ {
		info := nextString()
		// println(info)
		infos := strings.Split(info, ",")
		a, _ := strconv.Atoi(infos[0])
		b, _ := strconv.Atoi(infos[1])
		swap(nums, a-1, b-1)
	}
	for _, v := range nums {
		fmt.Println(v)
	}
}

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

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i = 0; i < (n);++i)
#define repc(i,a,b) for(int i = (a);i <(b);++i)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;

const int IMAX = ((1<<30)-1)*2+1 ;
const int INF = 100000000;
double EPS = 1e-10 ;

int main(){
  char c;
  int w,n,a,b,num,ans[5];
  bool flag = true;
  cin >> w >> n;
  vi v(w,0),va,vb ;
  rep(i,n){
    cin >> a >> c >> b ;
    va.pb(a),vb.pb(b) ;
  }

  rep(i,w){
    num = i+1 ;
    rep(j,n){
      if(num == va[j]){
        num = vb[j];
      }
      else if(num == vb[j]){
        num = va[j];
      }
    }
    ans[num-1] = i+1;
  }
  for(auto tmp :ans){
    cout << tmp << endl;
  }
  return 0;
}

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

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

C++: #include<stdio.h>
int line[30];
int n,m;
int a,b;
int mem[2];

int main()
{
    scanf("%d",&n);
    scanf("%d",&m);
    for(int i=0;i<n;i++)
    {
        line[i]=i+1;
    }
    for(int i=0;i<m;i++)
    {
        scanf("%d,%d",&a,&b);
        mem[0]=line[a-1];
        mem[1]=line[b-1];
        line[a-1]=mem[1];
        line[b-1]=mem[0];
    }
    for(int i=0;i<n;i++)
    {
        printf("%d\n",line[i]);
    }
}

C++: #include <stdio.h>

int main(void)
{
	int w,n;
	int l1, l2;
	int ans[30];
	int i;
	
	scanf("%d %d", &w, &n);
	
	for (i = 0; i < w; i++){
		ans[i] = i + 1;
	}
	
	while (n){
		scanf("%d%*c%d", &l1, &l2);
		
		ans[l1 - 1] += ans[l2 - 1];
		ans[l2 - 1] = ans[l1 - 1] - ans[l2 - 1];
		ans[l1 - 1] -= ans[l2 - 1];
		
		n--;
	}
	
	for (i = 0; i < w; i++){
		printf("%d\n", ans[i]);
	}
	
	return (0);
}

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

using namespace std;

int w,n;
int v[30];

int main(){
    for( int i = 0; i < 30; i++ )
    {
        v[i] = i + 1;
    }
    scanf( "%d \n%d\n", &w, &n );
    while( n > 0 )
    {
        int a,b;
        scanf( "%d,%d\n", &a, &b );
        swap( v[a - 1], v[b - 1] );
        n--;
    }
    
    for( int i = 0; i < w; i++ )
    {
        printf( "%d\n", v[i] );
    }
    return 0;
}

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]);
}