Problem A:
#include <cstdio>
#include <iostream>
using namespace std;
#define F(i,a,b) for(int i=a;i<b;i++)
int main(){
int n,x;
scanf("%d%d",&n,&x);
n %= 6;
while(n--){
if(n & 1){
if(x!=0) x=3-x;
}else{
if(x!=2) x=1-x;
}
}
cout<<x<<endl;
return 0;
}