var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var w=Arr.shift();
var n=Arr.shift();
var arr=[0];
for(var i=1;i<=w;i++)arr[i]=i;
for(var i=0;i<n;i++){
   var ab=Arr[i].split(",").map(Number);
   var a=ab[0];
   var b=ab[1];
   var x=arr[a];
   arr[a]=arr[b];
   arr[b]=x;
}
arr.shift();
console.log(arr.join("\n"));