Go: package main

import "fmt"

func main() {
	var w, n int
	fmt.Scan(&w)
	numbers := make([]int, w)

	fmt.Scan(&n)

	intersect := make([][2]int, n)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scanf("%d,%d", &x, &y)
		intersect[i] = [2]int{x, y}
	}

	for i := 0; i < w; i++ {
		numbers[i] = i + 1
	}

	for _, v := range intersect {
		swap(numbers, v[0], v[1])
	}

	for _, v := range numbers {
		fmt.Println(v)
	}
}

func swap(arr []int, x, y int) {
	tmp := arr[x-1]
	arr[x-1] = arr[y-1]
	arr[y-1] = tmp
}

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

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

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

C++: #include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
int main(){
	int w,n,a[30];
	scanf("%d%d",&w,&n);
	rep(i,w) a[i]=i+1;
	rep(i,n){
		string s;
		cin >> s;
		swap(a[s[0]-'1'],a[s[2]-'1']);
	}
	rep(i,w) printf("%d\n",a[i]);
	return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main(){
    int w, n;
    int d[31];
    while(cin >> w >> n){
        for(int i=1;i<=w;i++) d[i] = i;
        for(int i=0;i<n;i++){
            string s; cin >> s;
            istringstream iss >> s;
            for(int j=0;j<s.size();j++)
                if(s[j]==',') s[j] = ' ';
            int a, b; iss >> a >> b;
            swap(d[a], d[b]);
        }
        for(int i=1;i<=w;i++) cout << d[i] << endl;
    }
}

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

using namespace std;

int main(){

	int w,n;
	vector<pair<int,int> > lines;

	cin>>w>>n;
	for(int i = 0; i < n; i++){
		pair<int,int> p;
		char comma;
		cin >> p.first >> comma >> p.second;
		lines.push_back(p);
	}

	int ret[31];
	for(int i = 1; i <= w; i++){
		int cp = i;
		for(int j = 0; j < lines.size(); j++){
			if(lines[j].first == cp){
				cp = lines[j].second;
			}
			else if(lines[j].second == cp){
				cp = lines[j].first;
			}
		}
		//cout << cp << endl;
		ret[cp] = i;
	}
	for(int i = 1; i <= w; i++){
		cout << ret[i] << endl;
	}

	return 0;
}

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

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

int main() {
	int w, n, a, b;

	cin >> w >> n;
	auto hlines = vector<int>(w);
	for (int i = 0; i < w; ++i) {
		hlines.at(i) = i + 1;
	}

	for (int i = 0; i < n; ++i) {
		cin >> a;
		cin.ignore();
		cin >> b;
		--a, --b;
		swap(hlines.at(a), hlines.at(b));
	}
	for (int const x : hlines) {
		cout << x << endl;
	}
	return 0;
}

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

int main(void)
{
    int w, n;
    char c;
    int data[30][2];
    cin >> w >> n;
    for (int i = 0; i < n; ++i)
        cin >> data[i][0] >> c >>  data[i][1];

    for (int i = 1; i <= w; ++i) {
        int num = i;
        for (int j = n - 1; 0 <= j; --j) {
            if (data[j][0] == num)
                num = data[j][1];
            else if (data[j][1] == num)
                num = data[j][0];
        }
        cout << num << endl;
    }

    return 0;
}

C++: #include<stdio.h>

int main()
{
	int w,n,r=1,s;
	int a,b,x[64];
	scanf("%d%d",&w,&n);
	for(int i=0;i<w;i++){
		x[i]=r;
		r++;
	}
	for(int i=0;i<n;i++){
		scanf("%d,%d",&a,&b);
		s=x[a-1];
		x[a-1]=x[b-1];
		x[b-1]=s;
	}
	for(int i=0;i<w;i++){
		printf("%d\n",x[i]);
	}
	return 0;
}

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

int main(){

	int i,w,n,a[31],l,r,t;
	char c;

	for(i=1;i<31;i++)
		a[i]=i;

	cin >> w >> n;
	for(i=0;i<n;i++){
		cin >> l >> c >> r;
		t=a[l];
		a[l]=a[r];
		a[r]=t;
	}
	for(i=1;i<=w;i++){
		cout << a[i] << endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <vector>
using namespace std;
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);

	vector<int> res(n);
	vector<pair<int, int> > w;
	for (int i = 0; i < m; ++i) {
		int a, b;
		scanf("%d,%d", &a, &b);
		w.push_back(make_pair(a, b));
	}

	for (int i = 0; i < n; ++i) {
		int r = i+1;
		for (int j = 0; j < m; ++j) {
			if (w[j].first == r) r = w[j].second;
			else if (w[j].second == r) r = w[j].first;
		}
		res[r-1] = i+1;
	}
	for (int i = 0; i < n; ++i) printf("%d\n", res[i]);
	return 0;
}

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


int main(){
  int verticals,horizontals,a,b;
  char commma; //commaを抜くための変数
  cin >> verticals;
  cin >> horizontals;

  int res[verticals];
  for(int i=0;i<verticals;i++) res[i] = i+1;
  for(int i=0;i<horizontals;i++){
    cin >> a >> comma >> b;   
    int tmp = res[a-1];
    res[a-1] = res[b-1];
    res[b-1] = tmp;
  }
  for(int i=0;i<verticals;i++) cout << res[i] << endl;
}

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

using namespace std;

int main(){
  int w;
  int n;
  int a;
  int b;
  int a1;
  int b1;
  int c[50]={0};
  int i,j;
  char x;

  cin>>w>>n;
  for(i=1;i<=w;i++){
    c[i]=i;
  }
  for(i=1;i<=n;i++){
    cin>>a>>x>>b;
    swap(c[a],c[b]);
  }
  for(i=1;i<=w;i++){
    cout<<c[i]<<endl;
  }

  return 0;
}

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

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

C++: #include<iostream>

using namespace std;

#define DATA_MAX 50

void swap( int& a , int& b );

int main(void)
{
	int w, n;
	int a, b;

	int data[DATA_MAX];

	cin >> w;
	cin >> n;

	for( int i = 0 ; i < DATA_MAX ; i++ )
	{
		data[i] = i+1;
	}

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

	return 0;
}

void swap( int& a , int& b )
{
	int temp;

	temp = a;
	a = b;
	b = temp;

	return;
}

C++: #include<iostream>
#include<string.h>
#include<stdlib.h>
using namespace std;
int main()
{
    int A[50];
   string s;
   int w,n;
    A[0]=0;
   while(cin>>w>>n)
   {
        for(int i=1;i<=w;i++)
       {
           A[i]=i;
       }
       while(n--)
       {

       cin>>s;
       int len=s.length();
       int d=s.find(',',0);
       string a=s.substr(0,d);
       string b=s.substr(d+1,len-1);
       int c=atoi(a.c_str());
       int e=atoi(b.c_str());
      // cout<<a<<endl<<b<<endl<<c<<endl<<e<<endl;
         int h= A[c];
         A[c]=A[e];
         A[e]=h;

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

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,m;
  int lot[30];
  cin >>n>>m;
  for(int i=0; i<n; i++)
    lot[i] = i+1;
  while(m--){
    int x,y,z;
    scanf("%d,%d",&x,&y);
    z = lot[x-1];
    lot[x-1] = lot[y-1];
    lot[y-1] = z;
  }
  for(int i=0; i<n; i++)
    cout <<lot[i]<<endl;
  return 0;
}