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<bits/stdc++.h>
using namespace std;

int main(){
  int a[30];
  char gomi;
  int w,n,box1,box2;
  cin >> w >> n;
  for(int i=0;i<w;i++){
    a[i] = i+1;
  }
  for(int i=0;i<n;i++){
    cin >> box1 >> gomi >> box2;
    swap(a[box1-1],a[box2-1]);
  }
  for(int i=0;i<w;i++){
    cout << a[i] << endl;
  }
}

C++: #include<iostream>
#include<stdio.h>
#define N 30
using namespace std;
int main(){
????int w,n,tmp;
????int lod[N]; int lis[N][3];
????while(cin >> n >> w){
????for(int i = 0;i<n;i++){
????????lod[i] = i+1;
????}
??
????for(int i=0;i<w;i++){
????????scanf("%d,%d",&lis[i][0],&lis[i][2]);
????}
????for(int i=0;i<w;i++){
????????tmp = lod[lis[i][0]-1];
????????lod[lis[i][0]-1] = lod[lis[i][2]-1];
????????lod[lis[i][2]-1] = tmp;
????}
????for(int i=0;i<n;i++){
????????cout << lod[i] << endl;
????}
????}
}

C++: #include <iostream>

int main(){
	int a,b,c,g,h;
	char j;
	std::cin>>a>>b;
    int d[a];
    for(int e=1;e<=a;e++){
    	d[e]=e;
    	
	}
	for(int f=0;f<b;f++){
		std::cin>>g>>j>>h;
		c=d[g];
		d[g]=d[h];
		d[h]=c;
	}
	for(int i=1;i<=a;i++){
		std::cout<<d[i]<<std::endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <bitset>
#include <cmath>
#include <complex>
#include <vector>
#include <algorithm>

#define EPS 1e-6
using namespace std;

double cross(complex<double> a, complex<double> b)
{
  return a.real() * b.imag() - a.imag() * b.real();
}

double dot(complex<double> a, complex<double> b)
{
  return a.real() * b.real() + a.imag() * b.imag();
}

int main()
{
  int W, N;
  scanf(" %d %d ", &W, &N);
  vector<pair<int, int> > lines;
  for (int i = 0; i < N; i++) {
    int x, y;
    scanf(" %d,%d ", &x, &y);
    lines.push_back(make_pair(x, y));
  }
  reverse(lines.begin(), lines.end());
  vector<int> ans;
  for (int i = 0; i < W; i++) {
    int cur = i + 1;
    for (int j = 0; j < N; j++) {
      if (cur == lines[j].first) {cur = lines[j].second;}
      else if (cur == lines[j].second) {cur = lines[j].first;}
    }
    printf("%d\n", cur);
  }
  return 0;
}

C++: #include <stdio.h>

int main(void) {
	int w,n, a[30][2],i,c,no,rs[5];
	
	scanf("%d%d",&w,&n);
	for(i = 0; n > i; i++){
		scanf("%d",&a[i][0]);
		getchar();
		scanf("%d",&a[i][1]);
	}
	
	for(i = 1; w >= i; i++){
		no = i;
		for(c = 0; n > c; c++){
			if(a[c][0] == no) no = a[c][1];
			else if(a[c][1] == no) no = a[c][0];
		}
		rs[no-1] = i;
	}
	for(i = 0; w > i; i++){
		printf("%d\n",rs[i]);
	}
	
	return 0;
}

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

using namespace std;

int main() {
  int w,n;

  cin >> w >> n;

  vector<int> line(w);
  for(int i = 0; i < w; i++) {
    line[i]=i;
  }
  int t = 0;
  while(t < n) {
    int a,b;
    char c;
    cin >> a >> c  >> b;
    line[a-1] ^= line[b-1];
    line[b-1] ^= line[a-1];
    line[a-1] ^= line[b-1];
    
    t++;
  }

  for(auto l : line)
    cout << l+1 << endl;
  
  return 0;
}

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>
using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

typedef pair<int, int> P;

int dp[60];

int main()
{
	int w(0),n(0);
	REP(i, 60){
		dp[i] = i;
	}
	cin >> n >> w;
	REP(i, w){
		int a, b;
		char c;
		scanf("%d,%d", &a,&b);
		swap(dp[a], dp[b]);
	}
	REP(i, n){
		cout << dp[i+1] << endl;
	}
}

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(inti =a; i<n; i++)
using namespace std;
 
int main() {
int w,n; cin >> w >> n;
int a[31];
rep(i,0,w) a[i] = i+1;
 
rep(i,0,n) {
int x,y;
scanf("%d,%d",&x,&y);
swap(a[x-1],a[y-1]);
}
rep(i,0,n) cout << a[i] << endl;
return 0;
}

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

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

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

using namespace std;

int sosuu(int n);

int main(){
    int w=0;
    scanf("%d",&w);
    
    int n=0;
    scanf("%d",&n);
    
    int DL[w+1];
    for(int i=1; i<=w; i++){
        DL[i]=i;
    }
    
    for(int i=0; i<n; i++){
        int a,b;
        char c;
        scanf("%d%c%d",&a,&c,&b);
        int temp;
        temp=DL[a];
        DL[a]=DL[b];
        DL[b]=temp;
    }
    
    for(int i=1; i<=w; i++){
        printf("%d\n",DL[i]);

    }
    
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

int main() {
  int w, n, a[40][2], pos[40];
  cin >> w >> n;
  rep (i, n) scanf("%d,%d", a[i], a[i] + 1);
  rep (i, n) --a[i][0], --a[i][1];
  rep (i, w) pos[i] = i;
  rep (i, n) swap(pos[a[i][0]], pos[a[i][1]]);
  rep (i, w) cout << pos[i] + 1 << endl;
  return 0;
}

C++: #include <iostream>
using namespace std;
int main (){
	int w,N,d[30],c[30];
	cin>>w>>N;
	for(int j=1;j<=N;j++){
		d[j]=j;
		c[j]=d[j];
	}
	for(int i=0;i<w;i++){
		int a,b;
		cin>>a>>b;
		d[a]=d[b];
		d[b]=c[a];
		c[a]=d[a];
	}
	for(int k=0;k<N;k++){
	cout<<d[k]<<endl;
	}

	return 0;
}

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

int main(void)
{
	int lot[MAX], w, n;
	cin >> w >> n;
	for (int i = 0; i < w; i++) lot[i] = i+1;
	for (int i = 0; i < n; i++) {
		int a, b, tmp;
		scanf("%d,%d", &a, &b);
		tmp = lot[a-1];
		lot[a-1] = lot[b-1];
		lot[b-1] = tmp;
	}
	for (int i = 0; i < w; i++) cout << lot[i] << endl;
	
	return 0;
}

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

int main(){
	int w, n, i, tmp, a, b;
	cin>>w;
	cin>>n;
	vector<int> vw(w);
	vector<vector<int> > vn(n, vector<int>(2));
	for(i=0;i<w;i++) vw[i] = i+1;
	for(i=0;i<n;i++){
		scanf("%2d,%2d",&a, &b);
		vn[i][0] = a-1;
		vn[i][1] = b-1;
		
		tmp = vw[(vn[i][0])];
		vw[(vn[i][0])] = vw[(vn[i][1])];
		vw[(vn[i][1])] = tmp;
	}
	for(i=0;i<w;i++) cout << vw[i] << endl;
	return 0;
}

C++: #include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;






int main()
{
	int n, w;
	int a[30], b[30],c[30];
	cin >> w;
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf_s("%d,%d", &a[i], &b[i]);
		
	}
	for (int i = 1; i <= w; i++) {
		c[i] = i;
	}
	for (int i = 0; i < n; i++) {
		swap(c[a[i]], c[b[i]]);
	}
	for (int i = 1; i <= w; i++) {
		cout << c[i] << endl;
	}
	

}

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

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

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

int main() {
  int w, n, a, b, r[31], i, t;

  for (i = 1; i <= 30; i++) {
    r[i] = i;
  }

  cin >> w >> n;
  for (i = 0; i < n; i++) {
    scanf("%d,%d", &a, &b);
    t = r[a];
    r[a] = r[b];
    r[b] = t;
  }

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

  return 0;
}