intInp(){ char c = getchar(); int Neg = 1; while(c < '0' || c > '9'){ if(c == '-') Neg = -1; c = getchar(); } int Sum = 0; while(c >= '0' && c <= '9'){ Sum = ((Sum << 3) + (Sum << 1)) + c - '0'; c = getchar(); } return Neg * Sum; }
int Head[50010], Next[400010], End[400010]; bool Used[50010]; int Ans[50010], Index = 0; int Cou = 0;
voidLink(int a, int b){ Next[++Cou] = Head[a]; Head[a] = Cou; End[Cou] = b; }
boolDfs(int Cur, int Edge){ Used[Cur] = true; int Degree = 0; for(int x = Head[Cur]; x != -1; x = Next[x]){ if(Used[End[x]]) continue; if(Dfs(End[x], x)) Degree++; } if(Degree % 2 == 1) returnfalse; Ans[++Index] = (Edge + 1) >> 1; returntrue; }
intmain(){ memset(Head, -1, sizeof(Head)); int n = Inp(); int m = Inp(); for(int i = 1; i <= m; i++){ int a = Inp(); int b = Inp(); Link(a, b); Link(b, a); } for(int i = 1; i <= n; i++) if(!Used[i]) if(Dfs(i, -1)){ printf("-1"); return0; } std::sort(Ans + 1, Ans + Index + 1); printf("%d", Index); for(int i = 1; i <= Index; i++) printf("\n%d", Ans[i]); }