F. New Year's Puzzle
F. New Year's Puzzle
/*
短代码模拟就是我的人生理想
很妙的奇偶性:如果两个黑块的奇偶性不同
比如正好一上一下,这两个可以当成一组,也就意味着前面必然可以填满
*/
#include
using namespace std;
typedef long long ll;
#define debug(x) cout<<#x<<':'<mp;
int main(){
int T,x,y;
cin>>T;
while(T--){
mp.clear();
bool flag=true;
int n,m;cin>>n>>m;
vectorvc1,vc2,vc3;
for(int i=1;i<=m;i++){
cin>>x>>y;
mp[y]|=1<<(x-1);
}
int haslast=0,lastcolor=0;
mp[n+1]=3;
for(auto q:mp){
//debug(q.x);debug(q.y);cout<