#include iostream
using namespace std;
typedef struct LNode {
int data;
LNode *next;
}LNode,*List;
int main()
{
List head,p,q; //q起到游标的作用
int n,m,i;
head=(List)malloc(sizeof(LNode));
cin>>m>>n;
head->data=1;
head->next=head;
q=head;
for(i=2;i<=n;i++){
p=(List)malloc(sizeof(LNode));
p->data=i;
q->next=p;
p->next=head;
q=p;
} //循环链表创建
q=head;
int sum=n;
int M;
do{
M=m-1;
while(M--){
p=q;
q=q->next;
}
cout<<q->data<<endl; //输出节点元素
p->next=q->next;
free(q); //删除节点
sum--;
q=p->next;
}while(sum!=0);
return 0;
}