#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;
}