i=require("fs").readFileSync("/dev/stdin","utf8").split('\n'),w=+i[0],a=[];for(;a[w]=w--;);i.map(function(j){k=j.split(','),l=+k[0],m=+k[1];if(m)t=a[l],a[l]=a[m],a[m]=t});console.log(a.slice(1).join('\n'))