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++){
	swap(num[a[i]-1],num[b[i]-1]);
	}
	
	for(int i=0;i<w;i++)
		cout << num[i] <<endl;
}

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

using namespace std;

void Solution()
{
    int w, n;
    
    int temp; //data for swapping
    int a, b;
    char c;
        
    
    cin>>w;
    cin>>n;
    
    vector<int> v;
    
    for(int i = 0; i <= w; i++) // the smallest digit is 1
    {
        v.push_back(i);
    }
    
    for(int i = 0; i < n; i++)
    {
        cin>>a>>c>>b;
        
        temp = v[a]; //swap the position
        v[a] = v[b];
        v[b] = temp;
    }
    
    for(int i=1; i <= w; i++)
    {
        cout<<v[i]<<endl;
    }
}

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

C++: #include <cstdio>
using namespace std;
int main(){
  int *p,i,n,j,a1,b1,buf;
  scanf("%d",&n);
  p=new int[n];
  scanf("%d",&i);
  for(j=0;j<n;j++)p[j]=j+1;
  for(j=0;j<i;j++){
    scanf("%d,%d",&a1,&b1);
    a1--;b1--;
    buf=p[a1];
    p[a1]=p[b1];
    p[b1]=buf;
  }
  for(i=0;i<n;i++)printf("%d\n",p[i]);
}

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

int main(){
    int w, n;
    cin >> w >> n;
    int a, b;
    char com;
    vector<int> r;
    for (int i = 0; i <= w; i++) r.push_back(i);
    
    for (int i = 0; i < n; i++){
	cin >> a >> com >> b;
	swap(r[a], r[b]);
    }

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

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,l,n) for(i=l;i<n;i++)


int main(){
	int i,w,n,a,b,c[35],d;
	char k;

	cin>>w;
	cin>>n;
	//cout<<w<<" "<<n<<endl;
	rep(i,1,w+1){
		c[i]=i;
	}
	rep(i,1,n+1){
		cin>>a>>k>>b;
		//cout<<c[a]<<" "<<c[b]<<endl;
		swap(c[a],c[b]);
		//cout<<c[a]<<" "<<c[b]<<endl<<endl;
		
	}
	rep(i,1,w+1){
		cout<<c[i]<<endl;
	}
	

}

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

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

int main() {
	int w, n, a, b;
	char comma;
	vector<int> amida;
	cin >> w >> n;
	for (int i = 0;i < w;i++) amida.push_back(i + 1);

	for (int i = 0;i < n;i++) {
		cin >> a >> comma >> b;
		swap(amida.at(a - 1), amida.at(b - 1));
	}

	for (int i = 0;i < w;i++) {
		cout << amida.at(i) << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <sstream>
using namespace std;
int main() {
  int w;
  while (cin >> w) {
    vector<int> vec;
    vec.resize(w);
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n;
    cin >> n;
    cin.clear();
    // cin.ignore(INT_MAX, '\n');
    for (int i = 0; i < n; ++i) {
      string str, tmp_a, tmp_b;
      int a, b;
      getline(cin, str);
      istringstream iss(str);
      getline(iss, tmp_a, ',');
      getline(iss, tmp_b, ',');
      a = stoi(tmp_a) - 1;
      b = stoi(tmp_b) - 1;
      int tmp = vec[a];
      vec[a] = vec[b];
      vec[b] = tmp;
    }
    for (int i = 0; i < vec.size(); ++i) {
      cout << vec[i] << endl;
    }
  }
  return 0;
}

C++: #include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int main(){
    int w,n;
    int a[50],b[50],ans[50];
    scanf("%d%d",&w,&n);
    REP(i,n)
        scanf("%d,%d",a + i,b + i);

    FOR(i,1,w + 1){
        int now = i;
        REP(j,n){
            if(now == a[j])
                now = b[j];
            else if(now == b[j])
                now = a[j];
        }
        ans[now] = i;
    }
    FOR(i,1,w + 1)
        printf("%d\n",ans[i]);
    return 0;
}

C++: #include <cstdio>

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

        scanf("%d", &w);
        scanf("%d", &n);
        for (int i = 0; i < n; i++) {
                for (int j = 0; j < w; j++) {
                        lot[i][j] = -1;
                }
        }
        int a, b;
        for (int i = 0; i < n; i++) {
                scanf("%d,%d", &a, &b);
                lot[i][a - 1] = b - 1;
                lot[i][b - 1] = a - 1;
        }
        for (int i = 0; i < w; i++) {
                int cur = i;
                for (int j = 0; j < n; j++) {
                        if (lot[j][cur] >= 0) {
                                cur = lot[j][cur];
                        }
                }
                goal[cur] = i + 1;
        }
        for (int i = 0; i < w; i++) {
                printf("%d\n", goal[i]);
        }

        return 0;
}

C++: #include<cstdio>
int main(){
    int n,w;
    scanf("%d %d",&n, &w);
    int arr[n+1];
    for(int i=0; i<=n; i++)
        arr[i]=i;
    while(w--){
        char s[3];
        //scanf("%s", s);
        //int a=s[0]-'0', b=s[2]-'0';
        int a,b;
        scanf("%d,%d",&a,&b);
        //cin>>a>>,>>b;
        int memo=arr[a];
        arr[a]=arr[b];
        arr[b]=memo;
    }
    for(int i=1; i<=n; i++)
        printf("%d\n", arr[i]);
    return 0;
}

C++: #include<iostream>

int listen_lineCount();
void listen_path(int &from,int &to);

class Lots
{
private:
	int *start_goal;
	int verLineNum;
public:
	Lots(const int lineCount);
	~Lots();
	
	void draw_line(const int from,const int to);
	void echo_goalNums();
};

//-------------------------main--------------------------------

int main()
{
	int ver_lineCount=listen_lineCount();
	Lots inst_lot=Lots(ver_lineCount);
	
	int hor_lineCount=listen_lineCount();
	
	int from,to;
	for(int roop=0;roop<hor_lineCount;roop++)
	{
		listen_path(from,to);
		inst_lot.draw_line(from,to);
	}
	
	inst_lot.echo_goalNums();
	return 0;
}

//--------------------------------------------------------------

Lots::Lots(const int lineCount)
{
	verLineNum=lineCount;
	start_goal=new int(lineCount+2);
	
	for(int roop=1;roop<=lineCount;roop++)
	{
		start_goal[roop]=roop;
	}
}

Lots::~Lots()
{
	delete [] start_goal;
}

void Lots::draw_line(const int from,const int to)
{
	int swap=start_goal[from];
	start_goal[from]=start_goal[to];
	start_goal[to]=swap;
}

void Lots::echo_goalNums()
{
	using namespace std;
	
	for(int roop=1;roop<=verLineNum;roop++)
	{
		cout<<start_goal[roop]<<endl;
	}
}


int listen_lineCount()
{
	using namespace std;
	
	int lineCount;
	cin>>lineCount;
	
	return lineCount;
}

void listen_path(int &from,int &to)
{
	using namespace std;
	
	char delim;//カンマ区切り
	
	cin>>from>>delim>>to;
}