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>
using namespace std;

void swap(int &a,int &b){
	int tmp;
	tmp = a;
	a = b;
	b = tmp;
}

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

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

void swap(int *VerticalLine, int a, int b)
{
	int temp;

	temp = VerticalLine[a];
	VerticalLine[a] = VerticalLine[b];
	VerticalLine[b] = temp;
	
	return;
}

int main(void)
{
	int *VerticalLine;
	int *a, *b;
	int w, n;
	int i;
	
	scanf("%d", &w);
	scanf("%d", &n);
	
	VerticalLine = (int *)malloc(sizeof(int) * w);
	for(i = 0; i < w; ++i)
	{
		VerticalLine[i] = (i + 1);
	}
	a = (int *)malloc(sizeof(int) * n);
	b = (int *)malloc(sizeof(int) * n);
	
	for(i = 0; i < n; ++i)
	{
		scanf("%d,%d", &a[i], &b[i]);
	}
	
	for(i = 0; i < n; ++i)
	{
		swap(VerticalLine, (a[i] - 1), (b[i] - 1));
	}
	
	for(i = 0; i < w; ++i)
	{
		printf("%d\n", VerticalLine[i]);
	}
	
	free(VerticalLine);
	free(a);
	free(b);
	return 0;
}

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

int main(){
	int line[31];
	int w, n;
	string str;
	getline( cin, str );
	sscanf( str.c_str(), "%d", &w );
	getline( cin, str );
	sscanf( str.c_str(), "%d", &n );

	for( int i=1; i<=w; i++ ){
		line[i] = i;
	}
	for( int i=0; i<n; i++ ){
		int a, b;
		getline( cin, str );
		sscanf( str.c_str(), "%d,%d", &a, &b );
		int tmp = line[a];
		line[a] = line[b];
		line[b] = tmp;
	}

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

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

using namespace std;

int main(){
    int x,n;
    cin>>x>>n;
    int num[x];

    for(int i=0;i<x;i++){
        num[i]=i+1;
    }

    for(int i=0;i<n;i++){
        int a,b;
        char c;
        cin>>a>>c>>b;
        swap(num[a-1],num[b-1]);
    }

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

C++: #include <iostream>

using namespace std;

int main(){
	int w, n;
	int line[30];

	cin >> w;
	cin >> n;

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

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

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

	return 0;
}

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


main(){
  int a[31],b[31];
  int w,n;
  int num[31]={0,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};
  int temp;
  
  while(cin >> w){
    
    cin >> n;

    for(int i=1;i<=n;i++){
      //      cin >> a[i] >> ,>>b[i];
      scanf("%d,%d",&a[i],&b[i]);
    }

    for(int i=1;i<=n;i++){
      temp = num[a[i]];
      num[a[i]] =num[b[i]];
      num[b[i]] = temp;
    }

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



  
  return 0;

}

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

using namespace std;

int main()
{ 
	int w, n;
	cin >> w;
	cin >> n;

	vector<int> s(w + 1);
	for (int i = 1; i <= w; ++i)
		s[i] = i;

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

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

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

	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<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  char d[2];
  cin >> n >> m;
  int a[n],b,c;
  for(int i = 0;i < n;i++) a[i] = i+1;
  for(int i = 0;i < m;i++){
    cin >> b >> d[0] >> c;
    swap(a[b-1],a[c-1]);
  }
  for(int i = 0;i < n;i++)cout << a[i] << endl;
  return 0;
}

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

using namespace std;

int main()
{
	int w,n,a,b; cin >> w >> n;
	int* num = new int[w+1];

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

	delete[] num;
	return 0;
}

C++: #include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	
	int N=in();
	vector<int> V(N);
	iota(ALL(V),1);
	int Q=in();
	REP(i,Q){
		int a,b;
		scanf("%d,%d",&a,&b);
		swap(V[a-1],V[b-1]);
	}
	for(auto& x:V){
		out(x);
	}

	return 0;
}

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

#define FOR(i, a) for(int i=0;i<(int)a;++i)
typedef long long ll;
typedef long double ld;
using namespace std;

void solver() {
    int w, n;
    vector<int> a, b;
    vector<pair<int, int>> ans;
    cin >> w;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int ta, tb;
        scanf("%d,%d", &ta, &tb);
        a.push_back(ta);
        b.push_back(tb);
    }

    FOR(i, w) {
        auto p = i + 1;
        FOR(j, n) {
            if (p == a[j]) {
                p = b[j];
            } else if (p == b[j]) {
                p = a[j];
            }
        }
        ans.push_back({p, i + 1});
    }
    sort(ans.begin(), ans.end());

    FOR(i, w) cout << ans[i].second << " ";
    cout << endl;
}

int main() {
    solver();
    return 0;
}

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

class Amida{
public:
	void shokika(int a[],int b);
	void irekae(int bou[], int a, int b);
	void show(int bou[], int a);
};

void Amida::shokika(int a[],int b){
	for (int i = 0; i < b; i++){
		a[i] = i+1;
	}
}

void Amida::irekae(int bou[], int a, int b){
	int work;
	work = bou[a-1];
	bou[a-1] = bou[b-1];
	bou[b-1] = work;
}

void Amida::show(int bou[], int a){
	for (int i = 0; i < a; i++){
		cout << bou[i] << endl;
	}
}

int main(){
	int tate, yoko, *tatebou;
	Amida ami;
	cin >> tate >> yoko;

	tatebou = new int[tate];
	ami.shokika(tatebou, tate);

	int a, b;
	for (int i = 0; i < yoko; i++){
		scanf("%d,%d", &a, &b);
		ami.irekae(tatebou, a, b);
	}

	ami.show(tatebou,tate);

	return 0;
}