According to the meaning of the title, now suppose that the first move is white to move down xxx moves, then the black backhand can also go downxxStep x , at this time, there is no interference in the entire game.
In the same way, black moves upwards xxx moves, white moves upxxThe x- step does not affect the ending.
So the decisive factor is the interval between white and black.
Assuming the number of intervals is xxx , obviously any chess piece can take any number of steps in the interval, so the correspondingsg [x] = x sg[x]=xsg[x]=x , just ask for the answer directly at the end.
#include<bits/stdc++.h>
using namespace std;typedeflonglong ll;int a[105];intmain(){
int T, cas =0;scanf("%d",&T);while(T--){
int n;scanf("%d",&n);int ans =0;for(int i =1; i <= n;++i){
scanf("%d",&a[i]);}for(int i =1; i <= n;++i){
int t;scanf("%d",&t);
ans ^=(t - a[i]-1);}printf("Case %d: ",++cas);if(!ans)puts("black wins");elseputs("white wins");}return0;}