Go: package main

import "fmt"

func main() {
	var w, n, a, b, i, te int
	var amida [31]int
	fmt.Scanf("%d", &w)
	fmt.Scanf("%d", &n)
	for i := 1; i <= w; i++ {
		amida[i] = i
	}
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d,%d", &a, &b)
		te = amida[a]
		amida[a] = amida[b]
		amida[b] = te
	}
	for i := i; i <= w; i++ {
		fmt.Printf("%d\n", amida[i])
	}
}

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

}

C++: import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		//Scanner reader=new Scanner(System.in);
		String s=reader.readLine();
		int in=Integer.parseInt(s);
		//int in=reader.nextInt();
		int[] out=new int[in];
		for(int i=1;i<=in;i++)out[i-1]=i;
		//in=reader.nextInt();
		s=reader.readLine();
		in=Integer.parseInt(s);
		for(int i=0;i<in;i++){
			String s1=reader.readLine();
			String[] in1=s1.split(",");
			int a=Integer.parseInt(in1[0]);
			int b=Integer.parseInt(in1[1]);
			int tmp=out[a-1];
			out[a-1]=out[b-1];
			out[b-1]=tmp;
		}
		for(int i=0;i<out.length;i++)System.out.println(out[i]);
	}
}

C++: // includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int w, n;
  cin >> w >> n;
  vector<int> vec = vector<int>(w, 0);
  rep(i, w){
    vec[i] = i;
  }
  rep(i, n){
    string s;
    cin >> s;
    int a, b;
    rep(j, s.size()){
      if(s[j] == ','){
        a = stoi(s.substr(0, j));
        b = stoi(s.substr(j+1, -1));
        break;
      }
    }
    a--; b--;
    swap(vec[a], vec[b]);
  }
  rep(i, w){
    cout << vec[i] + 1 << endl;
  }
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int w,n;
  cin>>w>>n;
  vector<int> row(w);
  rep(i,w)row[i]=i+1;
  rep(i,n){
    int a,b;
    scanf("%d,%d",&a,&b);
    swap(row[--a],row[--b]);
  }
  rep(i,w)
    cout<<row[i]<<endl;


}

C++: #include <stdio.h>

int main()
{
	int a[50];
	int n,w;
	int x,y;
	int dummy;
	while(scanf("%d", &n) != EOF){
		scanf("%d", &w);
		for(int i = 1; i <= n; i++){
			a[i] = i;
		}
		for(int i = 0; i < w; i++){
			scanf("%d,%d", &x, &y);
			dummy = a[y];
			a[y] = a[x];
			a[x] = dummy;
		}
		for(int i = 1; i <= n; i++){
			printf("%d\n", a[i]);
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main() {
  int w, n;
  while (cin >> w >> n) {
    vector<int> vec;
    for (int i = 0; i < w; ++i) {
      vec.push_back(i + 1);
    }
    for (int i = 0; i < n; ++i) {
      int a, b;
      scanf("%d,%d", &a, &b);
      a -= 1;
      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;
}