#include #include #include using namespace std; using P=pair; int n, m; int a[200020], b[200020], c[200020]; vector

g[100010]; bool used[400040], finish[400040], ok; void dfs(int x, int prev){ for(auto p:g[x]){ int y=p.first, i=p.second; if(finish[i] || abs(i-prev)==m) continue; if(used[i]) ok=1; else{ used[i]=1; dfs(y, i); } finish[i]=1; } } int main() { scanf("%d %d", &n, &m); for(int i=0; i