#include using namespace std; const int N=10; int f[N][N][N][N]; int dfs(int a,int b,int c,int d){ if(a==0)return 1; if(f[a][b][c][d])return f[a][b][c][d]; f[a][b][c][d]=2; int ans=3; ans=min(ans,4-dfs(c,d,(a+b)%N,b)); ans=min(ans,4-dfs(c,d,(a+c)%N,b)); ans=min(ans,4-dfs(c,d,(a+d)%N,b)); ans=min(ans,4-dfs(c,d,(b+a)%N,a)); ans=min(ans,4-dfs(c,d,(b+c)%N,a)); ans=min(ans,4-dfs(c,d,(b+d)%N,a)); return f[a][b][c][d]=ans; } int main(){ for(int i=0;i<100;i++){ for(int a=1;a>t;t;t--){ cin>>a>>b>>c>>d; cout<