vector sideadj[N]; int selby[M]; int chk[M], c; bool matching(int s) { for(auto i : sideadj[s]) { if(chk[i] == c) continue; chk[i] = c; if(selby[i] and !matching(selby[i])) continue; selby[i] = s; return true; } return false; }