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>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i = 0; i < (n);++i)
#define repc(i,a,b) for(int i = (a);i <(b);++i)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;

const int IMAX = ((1<<30)-1)*2+1 ;
const int INF = 100000000;
double EPS = 1e-10 ;

int main(){
  char c;
  int w,n,a,b,num,ans[5];
  bool flag = true;
  cin >> w >> n;
  vi v(w,0),va,vb ;
  rep(i,n){
    cin >> a >> c >> b ;
    va.pb(a),vb.pb(b) ;
  }

  rep(i,w){
    num = i+1 ;
    rep(j,n){
      if(num == va[j]){
        num = vb[j];
      }
      else if(num == vb[j]){
        num = va[j];
      }
    }
    ans[num-1] = i+1;
  }
  for(auto tmp :ans){
    cout << tmp << endl;
  }
  return 0;
}

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

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

C++: #include<stdio.h>
int line[30];
int n,m;
int a,b;
int mem[2];

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

C++: #include <stdio.h>

int main(void)
{
	int w,n;
	int l1, l2;
	int ans[30];
	int i;
	
	scanf("%d %d", &w, &n);
	
	for (i = 0; i < w; i++){
		ans[i] = i + 1;
	}
	
	while (n){
		scanf("%d%*c%d", &l1, &l2);
		
		ans[l1 - 1] += ans[l2 - 1];
		ans[l2 - 1] = ans[l1 - 1] - ans[l2 - 1];
		ans[l1 - 1] -= ans[l2 - 1];
		
		n--;
	}
	
	for (i = 0; i < w; i++){
		printf("%d\n", ans[i]);
	}
	
	return (0);
}

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

using namespace std;

int w,n;
int v[30];

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

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

int main(){
  int w,n,i,j;
  int f,t;
  int value[31];
  for(i=1;i<31;i++){
    value[i]=i;
  }
  string str;
  cin >> w >> n;
  for(i=0;i<n;i++){
    cin >> str;
    if(str[1]==','){
      f = str[0] - '0';
      if(str.size()==3) t = str[2] - '0';
      else t = (str[2] - '0') * 10 + str[3] - '0';
    }else{
      f = (str[0] - '0') * 10 +  str[1] - '0';
      if(str.size()==4) t = str[3] - '0';
      else t = (str[3] - '0') * 10 + str[4] - '0';
    }
    int buf=value[f];
    value[f]=value[t];
    value[t]=buf;
  }
  for(i=1;i<w+1;i++){
    cout << value[i] << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
	int w, n;
	cin >> w;
	cin >> n;
	vector<int> l(w);
	rep(i, w)
	{
		l[i] = i+1;
	}
	
	rep(i, n)
	{
	    int a, b;
	    cin >> a;
	    cin.ignore();
	    cin >> b;
	    swap(l[a-1], l[b-1]);
	}
	
	rep(i, w)
	{
	    cout << l[i] << endl;
	}
}

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

using namespace std;

int main(void){
  int x,y,a,b,n[30];
  char s;

  cin >> y >> x;
  for(int i=0;i<y;i++)n[i]=i+1;

  for(int i=0;i<x;i++){
    cin >> a >> s >> b;
    swap(n[a-1],n[b-1]);
  }
  for(int i=0;i<y;i++)cout << n[i] << endl;

  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int stringTOlint(string s) {
	//string→lint
	lint Z = s.size();
	lint ret = 0;
	reverse(s);
	rep(i, Z) {
		ret += ((s[i] - '0') * pow(10, i));
	}
	return ret;
}

int main() {
	lint W, N;
	cin >> W >> N;
	vector<string>S(N);
	rep(i, N) {
		cin >> S[i];
	}
	bool flag = false;
	vector<string>A(N);
	vector<string>B(N);
	rep(i, N) {
		flag = false;
		rep(j, S[i].size()) {
			if (S[i][j] == ',') {
				flag = true;
			}
			else {
				if (flag) {
					B[i].push_back(S[i][j]);
				}
				else {
					A[i].push_back(S[i][j]);
				}
			}
		}
	}
	vector<lint>IA(N);
	vector<lint>IB(N);
	rep(i, N) {
		IA[i] = stringTOlint(A[i]);
		IB[i] = stringTOlint(B[i]);
	}
	lint now = 0;
	vector<lint>ANS;
	for (int i = 1; i <= W; i++) {
		now = i;
		rep(j, N) {
			if (IA[j] == now) {
				now = IB[j];
			}
			else if (IB[j] == now) {
				now = IA[j];
			}
		}
		ANS.push_back(now);
	}
	vector<IP>P(W);
	rep(i, W) {
		P[i].first = ANS[i];
		P[i].second = i + 1;
	}
	sort(P);
	rep(i, W) {
		cout << P[i].second << endl;
	}
}

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

int main(void){
    int w,n;
    std::cin>>w;
    std::vector<int> state(w+1);
    for(int i=1;i<=w;i++) state[i]=i;
    std::cin>>n;
    int a,b;
    for(int i=0;i<n;i++){
        scanf("%d,%d",&a,&b);
        std::swap(state[a],state[b]);
    }
    for(int i=1;i<=w;i++) std::cout<<state[i]<<std::endl;
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main()
{
    int m,n,a[30];
	cin >> m >> n;
	for(int i=0;i<m;i++)a[i]=i;
	for(int i=0;i<n;i++){
		string ss;
		cin >> ss;
		int x=ss[0]-'0';
		int y=ss[2]-'0';
		swap(a[x-1],a[y-1]);
	}
	for(int i=0;i<m;i++){
		printf("%d\n",a[i]+1);
	}
    return 0;
}

C++: #include<stdio.h>
 
int main(){
    int t[30];
    for(int i=0;i<30;i++)t[i]=i+1;
    int a,b;
    scanf("%d%d",&a,&b);
    for(int i=0;i<b;i++){
        int c,d;
        scanf("%d,%d",&c,&d);
        int s=t[c-1];
        t[c-1]=t[d-1];
        t[d-1]=s;
    }
    for(int i=0;i<a;i++)printf("%d\n",t[i]);
}

C++: #include <algorithm>
#include <iostream>
#include <limits>
#include <vector>
using namespace std;
int main() {
  int w, n;
  cin >> w >> n;
  vector<int> a(n), b(n), x(w);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cin.ignore(numeric_limits<unsigned>::max(), ',');
    cin >> b[i];
  }
  for (int i = 0; i < w; i++)
    x[i] = i + 1;
  for (int i = 0; i < n; i++)
    swap(x[a[i] - 1], x[b[i] - 1]);
  for (int i = 0; i < w; i++)
    cout << x[i] << endl;
}