#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int up[n],right[n],forward[n];
for(int i=0;i<n;i++)
{
up[i]=1;
right[i]=2;
forward[i]=4;
}
while(m--)
{
int a,b;
cin>>a>>b;
if(a>0 && b>0)
{
swap(up[a-1],up[b-1]);
swap(forward[a-1],forward[b-1]);
swap(right[a-1],right[b-1]);
}
else if(b==-1)
{
int temp=up[a-1];
up[a-1]=7-forward[a-1];
forward[a-1]=temp;
}
else if(b==-2)
{
int temp=up[a-1];
up[a-1]=7-right[a-1];
right[a-1]=temp;
}
}
for(int i=0;i<n;i++)
{
cout<<up[i]<<" ";
}
}