#include<iostream>

using namespace std;



int main(){
  int w=1,n=0;

  cin>>w>>n;
  int a_b[n][2];
  int out[n+1];//don't use out[0]
  for(int i=0;i<n;i++){
    cin>>a_b[i][0];
    cin.ignore();
    cin>>a_b[i][1];
  }
  
  for(int i=0; i<w; i++){
    int now=i+1;//I want to use out[] from 1 because now start 1
    for(int j=0; j<n; j++){
      if(a_b[j][0]==now)now = a_b[j][1];
      else if(a_b[j][1]==now)now = a_b[j][0];
     
    }
    out[now]=i+1;
  }
  for(int i=1;i<=w; i++){
    cout<<out[i]<<endl;
  }

}