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 <utility>
#include <algorithm>
#include <vector>
#include <sstream>

using hline_t = std::pair<unsigned, unsigned>;

int main(int argc, char const* argv[])
{
	unsigned w, n;
	std::cin >> w >> n ;
	std::vector<hline_t> hlines;
	for (int i = 0; i < n; i++) {
		std::string s;
		hline_t h;
		std::getline(std::cin, s, ',');
		h.first = std::stoi(s);
		std::getline(std::cin, s);
		h.second = std::stoi(s);
		hlines.push_back(h);
	}
	std::vector<unsigned> v(w + 1);
	{
		unsigned n = 0;
		std::generate(v.begin(), v.end(), [&n](){ return n++; });
	}

	for (auto var : hlines) {
		std::swap(v[var.first], v[var.second]);
	}
	std::for_each(v.begin() + 1, v.end(), [&](auto v){ std::cout << v << std::endl; });
	
	return 0;
}

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

int main() {
  int w, n;
  cin >> w >> n;
  int ans[n];

  for (int i=0; i<w; i++)
    ans[i] = i+1;
  for (int i=0; i<n; i++) {
    string s;
    cin >> s;
    int a = s[0] - '1';
    int b = s[2] - '1';
    swap(ans[a], ans[b]);
  }
  for (int i=0; i<w; i++)
    cout << ans[i] << endl;
}

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

int main(void){
    int w=0, n;
	cin>>w;
	vi x(w);
	for (int i=0; i<w; i++)
		x[i] = i+1;

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

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

C++: #include<iostream>
#include<vector>
 
int main()
{
    int w,n;
 
    char c;
 
    std::cin >> w >> n;
 
    std::vector<int> a(n);
 
    std::vector<int> b(n);
 
    std::vector<int> x(w);
 
    for(int i=0;i<n;++i)
    {
        std::cin >> a[i] >> c >> b[i];
    }
 
    for(int i=0;i<w;++i)
    {
        x[i]=i+1;
    }
 
    for(int i=0;i<n;++i)
    {
        int temp = x[a[i]-1];
 
        x[a[i]-1]=x[b[i]-1];
 
        x[b[i]-1]=temp;
    }
 
    for(int i=0;i<w;++i)
    {
        std::cout << x[i] << '\n';
    }
}

C++: #include<stdio.h>
int main(void){
	int w,n,x,y,temp;
	int a[31];
	char str[7];
	for(int i = 0; i < 31; i++){
		a[i] = i;
	}
	scanf("%d %d",&w,&n);
	for(int i = 0; i < n; i++){
		getline(str);
		if(str[3] == ',')
			str[3] = ' ';
		else
			str[2] = ' ';
		sscanf(str,"%d %d",&x,&y);
		temp = a[x];
		a[x] = a[y];
		a[y] = temp;
	}

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

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.dl", "r", stdin);
	string str = "";
	string res = "";
	int w;
	int n;

	getline (cin, str );
	stringstream ssw(str);
	ssw >> w;

	vector <int> Aj (w, 0);
	int i;
	for (i = 0; i < w; ++i){
		Aj[i] = i;
	} // end for
			
	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	for (i = 0; i < n; ++i){
		getline (cin, str );
		int a,b;
		str = str.replace(str.find(','), 1, " ");

		stringstream ss(str);
		ss >> a >> b;
//		cout << "a: " << a << " b: " << b << endl;
		swap(Aj[a-1], Aj[b-1]);
	} // end for

	for (i = 0; i < w; ++i){
		cout << (Aj[i] + 1) << endl;	
	} // end for
	
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
typedef pair<int,int> p;

int main()
{
	int w,n; cin>>w>>n;
	int ans[w];
	p sticks[n];
	char tmp;
	for(int i=0;i<n;i++)
	{
		cin>>sticks[i].first>>tmp>>sticks[i].second;
	}


	for(int i=0;i<w;i++)
	{
		int now=i+1;
		for(int j=0;j<n;j++)
		{
			if(sticks[j].first==now) now=sticks[j].second;
			else if(sticks[j].second==now) now=sticks[j].first;
		}
		ans[now-1]=i+1;
	}
	for(int i=0;i<w;i++) cout<<ans[i]<<endl;
	return 0;
}

C++: #include<stdio.h>

int w,n;
int a[31];
int x,y;
int k;

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

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

int main(){
vector<int>v;
int w,n;
int a,b;
char m;
cin>>w>>n;
for(int i=0;i<w;i++){
	v.push_back(i+1);
	}
	
	for(int i=0;i<n;i++){
cin>>a>>m>>b;
		swap(v[a],v[b]);
		}
		
		for(int i=0;i<w;i++){
			cout<<v[i]<<endl;
			}
			
		return 0;
		
		}

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

#define ll (long lon
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)

using namespace std;

int main (void){
    
    int tate,bnumber;
    int bridge[31][2] = {0};
    int answer[31] = {0};
    bool roopjudge = true;
    int temp = 0;
    int tempnumber = 0;
    int i,j,k,l;
    
    cin >> tate >> bnumber;
    for(i = 0;i< bnumber;i++)
        scanf("%d%*c%d",&bridge[i][0],&bridge[i][1]);
    /*
    REP(i, bnumber)
    cout << bridge[i][0] << ","<< bridge[i][1] << endl;
    */
    
    for(i = 1; i<=tate; i++)
    {
        temp = i;
        for(k = 0; k<bnumber;k++)
        {
            if(temp == bridge[k][0])
                temp = bridge[k][1];
            else if(temp == bridge[k][1])
                temp = bridge[k][0];
        }
        answer[temp] = i;
    }
    
    REP(i,tate)
    cout << answer[i+1] << endl;
    return 0;
    
}

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

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

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

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

using namespace std;

int amida[31][31] = { 0 };

int main(){

    int W, n;

    cin >> W;
    for (int vertical = 1; vertical <= W; vertical++){
        amida[vertical][0] = vertical;
    }

    cin >> n;
    for (int horizonal = 1; horizonal <= n; horizonal++){
        int a, b;
        scanf("%d,%d", &a, &b);

        for (int i = 1; i <= W; i++){
            if (i == a){
                amida[i][horizonal] = amida[b][horizonal - 1];
            }
            else if (i==b)
            {
                amida[i][horizonal] = amida[a][horizonal - 1];
            }
            else
            {
                amida[i][horizonal] = amida[i][horizonal - 1];
            }
        }
    }

    for (int i = 1; i <= W;i++){
        cout << amida[i][n] << endl;
    }

    return 0;
}

C++: #include<stdio.h>

int main(void){
	int ans[50],temp;
	int a,b,w,n;

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