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

int main(){
  int w;
  int n;
  vector<int> vertical;
  int a,b;

  cin>>w;

  for(int i=1;i<=w;++i)
    vertical.push_back(i);

  cin>>n;

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

  for(auto i:vertical)
    cout<<i<<endl;

}

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

using namespace std;
 
int main() {
  int w, n;
  cin >> w >> n;
  int ans[n];
 
  for(int i=0;i<=w;i++)
    ans[i] = i;
    
  for(int i=0;i<n;i++) {
  	
    int a, b;
    cin >> a >> b;
    swap(ans[a], ans[b]);
    
  }
  for (int i=1; i<=w;i++)
    cout << ans[i] << "\n";
    return 0;
}

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

using namespace std;

int main(void){
     int w[30];
     int line;
     int n;
     int a1,b1;
     for(int i = 0;i<30;i++){
	  w[i] = i+1;
     }
     cin >> line;
     cin >> n;
//     for(int i=0;i<line;i++){
//	  cout << w[i] << endl;
//     }
//     cout << endl;

     for(int i=0;i<n;i++){
	  scanf("%d,%d",&a1,&b1);
	  int m = w[a1-1];
	  w[a1-1] = w[b1-1];
	  w[b1-1] = m;
//	  for(int i=0;i<line;i++){
//	       cout << w[i] << endl;
//	  }
//	  cout << endl;
     }

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

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

int main(){
	int w,n;
	cin>>w>>n;
	int a[w];
	for(int i=0;i<w;i++) a[i]=i+1;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		int x=s[0]-'1';
		int y=s[2]-'1';
		int z=a[x];
		a[x]=a[y];
		a[y]=z;
	}
	for(int i=0;i<w;i++) cout<<a[i]<<endl;
	return 0;
}

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


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

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#define fi first
#define se second
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	int w;
	int n;
	int y;
	char c;
	int a[35],b[35];
	int x[35];
	cin>>w>>n;
	for(int i=1;i<=w;i++) x[i]=i;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>c>>b[i];
	}
	for(int i=1;i<=n;i++){
		y=x[a[i]];
		x[a[i]]=x[b[i]];
		x[b[i]]=y;
	}
	for(int i=1;i<=w;i++){
		cout<<x[i]<<endl;
	}
}

C++: #include <stdio.h>

void swap(int array[], int a, int b){
	int c;
	c = array[a];
	array[a] = array[b];
	array[b] = c;
}

int main(){
	int array[50];
	int w,n,a,b;

	for(int i=0 ; i<50 ; i++){
		array[i] = i;
	}
	
	scanf("%d", &w);
	scanf("%d", &n);
	for(int i=0 ; i<n ; i++){
		scanf("%d,%d", &a, &b);
		swap(array,a,b);
	}
	for(int i=1 ; i<=w ; i++){
		printf("%d\n", array[i]);
	}
}

C++: #include <stdio.h>
#define MAX 30

int main(void){
    int w,n, tmp;
    int a,b;
    int lot[MAX+1]; // 1-origin

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

    return 0;
}

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

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

C++: #include<stdio.h>

int main(void){
int i,tate,yoko,a,b,temp ;
int array[] = {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} ;

scanf("%d %d",&tate,&yoko);

for(i=0; i<yoko; i++){
scanf("%d,%d",&a,&b);
a--;//for array index
b--;//for array index
temp = array[a] ;//swap values
array[a] = array[b] ;
array[b] = temp ;
}

for(i=0; i<tate; i++){
printf("%d\n",array[i]);
}

return 0 ;
}

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

int main(void){
	int w,n;
	int a,b;
	int line[30];
	int i;
	char comma;

	for(i=0;i<30;i++){
		line[i]=i+1;
	}
	cin >> w;
	if(w<=30&&w>0){
		cin >> n;
		for(i=0;i<n;i++){
			cin >> a >> comma >> b;
			if(a>0&&b>0&&a<=w&&b<=w) swap(line[a-1],line[b-1]);
		}
		for(i=0;i<w;i++){
			cout << line[i];
			if(i==w-1) cout << endl;
			else cout << " ";
		}
	}
	return 0;
}

C++: #include<iostream>

int main(){
		int w,n,i,a[31],y,z,j;
		char x;
		std::cin>>w;
		std::cin>>n;
		for(i=1;i<=w;i++){
			a[i]=i;
		}
		for(i=0;i<n;i++){
			std::cin>>y>>x>>z;
			j=a[y];
			a[y]=a[z];
			a[z]=j;
		}
		for(i=1;i<=w;i++){
		std::cout<<a[i]<<std::endl;
		}


	return 0;
}

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

using namespace std;

int a[31];

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

    for (int i = 1; i <= w; ++i) a[i] = i;

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

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

C++: #include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl


long res[30];
long from[30],to[30];

int main(){
	li w,n;
	cin>>w>>n;
	
	rep(i,w)res[i]=i;
	
	rin{
		scanf("%ld,%ld", &from[i], &to[i]);
	}
	
	rin{
		swap(res[from[i]-1],res[to[i]-1]);
	}
	
	rep(i,w)cout<<res[i]+1<<endl;
	
	return 0;
}

C++: #include <stdio.h>

void swap(int array[], int a, int b){
	int c;
	c = array[a];
	array[a] = array[b];
	array[b] = c;
}

int main(){
	int array[50];
	int w,n,a,b;

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

C++: #include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int w,n;
    int W[30],a,b;
    
cin>>w>>n;
    for(int i=1;i<=30;i++){
       W[i]=i;
    }
       for(int i=1;i<=n;i++){
        (cin>>a).ignore()>>b;
swap(W[a],W[b]);
    } 
        for(int i=1;i<=w;i++){
    cout<<W[i]<<endl;
        }
}