Go: package main

import (
        "fmt"
)

const MAX_N = 31
var lines [MAX_N]int

func main() {
        var n, w int
        fmt.Scanf("%d", &n)
        fmt.Scanf("%d", &w)

        Init()
        var l, r int
        for {
                _, err := fmt.Scanf("%d,%d", &l, &r)
                if err != nil {
                        break
                }

                Swp(l, r)
        }

        for i := 1; i <= n; i++ {
                fmt.Printf("%d\n", lines[i])
        }
}

func Swp(l int, r int) {
        var s int
        s = lines[l]
        lines[l] = lines[r]
        lines[r] = s
}

func Init() {
        for i := 0; i < MAX_N; i++ {
                lines[i] = i
        }
}

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

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

C++: #include <iostream>

using namespace std;

int main() {
	int a[31];
	for(int i=0;i<31;i++){
		a[i] = i;
	}
	int w,n;
	cin >> w;
	cin >> n;
	int k,l;
	while(scanf("%d,%d",&k,&l)+1){
		a[0] = a[k];
		a[k] = a[l];
		a[l] = a[0];
	}
	for(int i=1;i<=w;i++){
		cout << a[i] << endl;
	}
	return 0;
}

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

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

C++: #include<iostream>
using namespace std;
int x[40], n, w, a, b, c, d; char f;
int main() {
	cin >> n >> w;
	for (int i = 1; i <= n; i++) {
		x[i] = i;
	}
	for (int i = 0; i < w; i++) {
		cin >> a >> f >> b;
		c = x[a];
		d = x[b];
		x[a] = d;
		x[b] = c;
	}
	for (int i = 1; i <= n; i++) {
		cout << x[i] << endl;
	}
}

C++: #include <vector>
#include <iostream>
using namespace std;
 
int main(){
    int w, n,a,b;
    char c;
    vector<int> ans;
    cin >> w >> n;


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

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

C++: #include <stdio.h>

int main()
{
	int w, n, a, b, x, rs[30];

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

	for(int i = 0; i < w; i++){
		rs[i] = i+1;

		printf("%d\n", rs[i]);
	}

	for(int i = 0; i < n; i++){
		scanf("%d %d", &a, &b);

		x = rs[a-1];
		rs[a-1] = rs[b-1];
		rs[b-1] = x;
	}

	for(int i = 0; i < w; i++){
		printf("%d\n", rs[i]);
	}
	
	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.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 <iostream>
#define for1(be,end,z) for(z=be;z<end;z++)
#define for2(end,z) for1(0,end,z)

using namespace std;
int g_lost[30];
void init()
{
    int i;
    for2(30,i)
    {
        g_lost[i]=i+1;
    }
}
void swap1(int a,int b)
{
    int tp;
    tp=g_lost[a-1];
    g_lost[a-1]=g_lost[b-1];
    g_lost[b-1]=tp;
}
int main()
{
    init();
    int w,n,i;
    cin>>w;
    cin>>n;
    while(n--)
    {
        char a,b,p;
        cin>>a>>p>>b;
        swap1(a-0x30,b-0x30);
    }
    for2(w,i)
    {
        cout<<g_lost[i];
        if(i!=w)cout<<endl;
    }
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int w, n;
    int lots[31];
    cin>>w>>n;
    for(int i=0; i<=w; i++) lots[i]=i;
    for(int i=0; i<n; i++){
        int a, b;
        cin>>a;
        cin.ignore();
        cin>>b;
        swap(lots[a], lots[b]);
    }
    for(int i=1; i<=w; i++) cout<<lots[i]<<'\n';
    return 0;
}

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

const int MAXN = 33;
int w, n;
int a[MAXN], b[MAXN];

int main() {
  while(cin >> w) {
    cin >> n;
    for(int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      replace(s.begin(), s.end(), ',', ' ');
      stringstream ss(s);
      ss >> a[i] >> b[i];
      --a[i];
      --b[i];
    }
    int res[w];
    for(int j = 0; j < w; ++j) {
      int p = j;
      for(int i = 0; i < n; ++i) {
	if(p == a[i]) {
	  p = b[i];
	} else if(p == b[i]) {
	  p = a[i];
	}
      }
      res[p] = j;
    }
    for(int j = 0; j < w; ++j) {
      cout << res[j]+1 << endl;
    }
  }
  return 0;
}

C++: #include <stdio.h>
int main(){
    int w[30],work,tate,yoko,i,i2,memo;
    int a1,a2;
    scanf("%d",&tate);
    scanf("%d",&yoko);
    for(i=0;i<tate;i++){
        w[i]=i+1;
    }
    for(i=1;i<=yoko;i++){
        scanf("%d,%d",&a1,&a2);
        for(i2=1;i2<=tate;i2++){
            if(i2==a1){
                work=w[i2-1];
                memo=i2-1;
            }
            if(i2==a2){
                w[memo]=w[i2-1];
                w[i2-1]=work;
            }
        }
    }
    for(i=0;i<tate;i++){
        printf("%d\n",w[i]);
    }
    
	return 0;
}

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

using namespace std;

int main(void) {


	//0011
	int Line[31], w=0, n=0, a, b, tmp;
	cin >> w;
	cin >> n;
	for (int i=0; i < 31; i++) {
		Line[i] = i;
	}
	for (int j = 0; j < n; j++) {
		scanf("%d,%d", &a, &b);
		tmp = Line[a];
		Line[a] = Line[b];
		Line[b] = tmp;
	}
	for (int k = 1; k <= w; k++) {
		cout << Line[k] << endl;
	}


	return 0;
}

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

int ans[31];

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

C++: #include <algorithm>
#include <sstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

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

	cin >> w >> n;

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

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

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

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

using namespace std;

int w;//縦本の総本数
int n;//横棒の数
int D[30];//あみだの並び順


queue<pair<int,int> > que;
int a,b;
int temp;

int main(){
  scanf("%d\n%d",&w,&n);
  for(int i = 1;i <= w;i++){
    D[i] = i;
  }//あみだを初期化
  for(int i = 0;i < n;i++){
    scanf("%d,%d",&a,&b);
    que.push(pair<int,int>(a,b));
  }
  for(int i = 0;i <n;i++){
    a =que.front().first;
    b =que.front().second;
    temp = D[b];
    D[b] = D[a];
    D[a] = temp;
    que.pop();
  }
  for(int i = 1;i <=w;i++){
    printf("%d\n",D[i]);
  }

}