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

#define add push_back
#define inf 2147000000

#define rep(i,n) for(int i=0;i<n;i++)
#define out(a) cout<<a<<endl;

using namespace std;

int main(void){
	int w,h;
	int y1[30],y2[30],t[31];
	string str;
	scanf("%d%d",&w,&h);
	rep(i,h){
		cin>>str;
		y1[i] = str[0]-48;
		y2[i] = str[2]-48;
	}
	rep(i,31)t[i]=i;
	
	rep(i,h){
		swap(t[y1[i]],t[y2[i]]);
	}
	
	rep(i,w)out(t[i+1]);
}

C++: #include<iostream>
using namespace std;
int main()
{
  int tate,yoko,lot[31];
  cin >> tate >> yoko;
  for(int i=1; i<=tate; i++)
    lot[i]=i;
  while(yoko-->0){
    int a,b,temp;
    char x;
    cin >> a >> x >> b;
    temp=lot[a];
    lot[a]=lot[b];
    lot[b]=temp;
  }
  for(int i=1; i<=tate; i++)
    cout << lot[i] << endl;
}

C++: #include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

pair<int, int> p;
int a[31];

int main()
{
	int w, n, r;
	cin >> w >> n;
	for (int i = 1; i < w + 1; i++)
		a[i] = i;
	for (int i = 0; i < n; i++)
	{
		scanf_s("%d,%d", &p.first, &p.second);
		r = a[p.first];
		a[p.first] = a[p.second];
		a[p.second] = r;
	}
	for (int i = 1; i < w + 1; i++)
	{
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(void){
	int w,n;
	int a,b;
	int i;
	char ch;
	int m[31];
	cin>>w>>n;
	for(i=1;i<=w;i++)	m[i]=i;
	for(i=0;i<n;i++){
		cin>>a>>ch>>b;
		swap(m[a],m[b]);
	}
	for(i=1;i<=w;i++)	cout<<m[i]<<endl;
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_N=30;

int n,w;
int a[MAX_N],b[MAX_N];

char s[8];

int main(){
	scanf("%d",&w);
	scanf("%d",&n);
	REP(i,n){
		scanf("%s",s);
		int l=strlen(s);
		b[i]=-1;
		REP(j,l){
			if (s[j]!=','){
				if (b[i]==-1){
					a[i]*=10;
					a[i]+=s[j]-'0';
				}
				else{
					b[i]*=10;
					b[i]+=s[j]-'0';
				}
			}
			else{
				b[i]=0;
			}
		}
	}
	FOR(i,1,w+1){
		int c=i;
		for(int j=n-1;j>=0;j--){
			if (c==a[j]){
				c=b[j];
			}
			else if (c==b[j]){
				c=a[j];
			}
		}
		printf("%d\n",c);
	}
	return 0;
}

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

int main(){

	using namespace std;

	vector<int> array;
	int w,n;
	int a,b,i,j;
	
	scanf("%d %d\n",&w,&n);
	
	for(i=0;i<w;i++){
		array.push_back(i+1);
	}
	
	for(i=0;i<n;i++){
		scanf("%d,%d",&a,&b);
		array[a-1]=b;
		array[b-1]=a;
	}
	
	for(i=0;i<w;i++){
		cout << array[i] << endl;
	}
}

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

void swap(int &a,int &b){
	int tmp;
	tmp = a;
	a = b;
	b = tmp;
}

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

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

void swap(int *VerticalLine, int a, int b)
{
	int temp;

	temp = VerticalLine[a];
	VerticalLine[a] = VerticalLine[b];
	VerticalLine[b] = temp;
	
	return;
}

int main(void)
{
	int *VerticalLine;
	int *a, *b;
	int w, n;
	int i;
	
	scanf("%d", &w);
	scanf("%d", &n);
	
	VerticalLine = (int *)malloc(sizeof(int) * w);
	for(i = 0; i < w; ++i)
	{
		VerticalLine[i] = (i + 1);
	}
	a = (int *)malloc(sizeof(int) * n);
	b = (int *)malloc(sizeof(int) * n);
	
	for(i = 0; i < n; ++i)
	{
		scanf("%d,%d", &a[i], &b[i]);
	}
	
	for(i = 0; i < n; ++i)
	{
		swap(VerticalLine, (a[i] - 1), (b[i] - 1));
	}
	
	for(i = 0; i < w; ++i)
	{
		printf("%d\n", VerticalLine[i]);
	}
	
	free(VerticalLine);
	free(a);
	free(b);
	return 0;
}

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

int main(){
	int line[31];
	int w, n;
	string str;
	getline( cin, str );
	sscanf( str.c_str(), "%d", &w );
	getline( cin, str );
	sscanf( str.c_str(), "%d", &n );

	for( int i=1; i<=w; i++ ){
		line[i] = i;
	}
	for( int i=0; i<n; i++ ){
		int a, b;
		getline( cin, str );
		sscanf( str.c_str(), "%d,%d", &a, &b );
		int tmp = line[a];
		line[a] = line[b];
		line[b] = tmp;
	}

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

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

using namespace std;

int main(){
    int x,n;
    cin>>x>>n;
    int num[x];

    for(int i=0;i<x;i++){
        num[i]=i+1;
    }

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

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

C++: #include <iostream>

using namespace std;

int main(){
	int w, n;
	int line[30];

	cin >> w;
	cin >> n;

	for(int i = 0; i < 30; i++){
		line[i] = i+1;
	}

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

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

	return 0;
}

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


main(){
  int a[31],b[31];
  int w,n;
  int num[31]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
	       21,22,23,24,25,26,27,28,29,30};
  int temp;
  
  while(cin >> w){
    
    cin >> n;

    for(int i=1;i<=n;i++){
      //      cin >> a[i] >> ,>>b[i];
      scanf("%d,%d",&a[i],&b[i]);
    }

    for(int i=1;i<=n;i++){
      temp = num[a[i]];
      num[a[i]] =num[b[i]];
      num[b[i]] = temp;
    }

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



  
  return 0;

}

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

using namespace std;

int main()
{ 
	int w, n;
	cin >> w;
	cin >> n;

	vector<int> s(w + 1);
	for (int i = 1; i <= w; ++i)
		s[i] = i;

	while (n--)
	{
		int a, b;
		scanf("%d,%d", &a, &b);

		swap(s[a], s[b]);
	}

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

	return 0;
}

C++: #include<stdio.h>

int main(){
int tate,yoko,bou[30][2],j,x,kekka[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30},i=0;
scanf("%d %d",&tate,&yoko);
for(j=0;j<yoko;j++){
scanf("%d %d",&bou[j][1],&bou[j][2]);
}
for(i=1;i<tate+1;i++){
x=i;
for(j=0;j<yoko;j++){
if(bou[j][1]==x){
x=bou[j][2];
}
else if(bou[j][2]==x){
x=bou[j][1];
}
}
kekka[x-1]=i;
}
for(j=0;j<tate;j++){
printf("%d\n",kekka[j]);
}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  char d[2];
  cin >> n >> m;
  int a[n],b,c;
  for(int i = 0;i < n;i++) a[i] = i+1;
  for(int i = 0;i < m;i++){
    cin >> b >> d[0] >> c;
    swap(a[b-1],a[c-1]);
  }
  for(int i = 0;i < n;i++)cout << a[i] << endl;
  return 0;
}

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

using namespace std;

int main()
{
	int w,n,a,b; cin >> w >> n;
	int* num = new int[w+1];

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

	delete[] num;
	return 0;
}