#include <bits/stdc++.h>   #pragma GCC optimize(2)   #pragma GCC optimize(3)   #pragma GCC optimize( Ofast )   #pragma GCC optimize( inline )   #pragma GCC optimize( -fgcse )   #pragma GCC optimize( -fgcse-lm )   #pragma GCC optimize( -fipa-sra )   #pragma GCC optimize( -ftree-pre )   #pragma GCC optimize( -ftree-vrp )   #pragma GCC optimize( -fpeephole2 )   #pragma GCC optimize( -ffast-math )   #pragma GCC optimize( -fsched-spec )   #pragma GCC optimize( unroll-loops )   #pragma GCC optimize( -falign-jumps )   #pragma GCC optimize( -falign-loops )   #pragma GCC optimize( -falign-labels )   #pragma GCC optimize( -fdevirtualize )   #pragma GCC optimize( -fcaller-saves )   #pragma GCC optimize( -fcrossjumping )   #pragma GCC optimize( -fthread-jumps )   #pragma GCC optimize( -funroll-loops )   #pragma GCC optimize( -fwhole-program )   #pragma GCC optimize( -freorder-blocks )   #pragma GCC optimize( -fschedule-insns )   #pragma GCC optimize( inline-functions )   #pragma GCC optimize( -ftree-tail-merge )   #pragma GCC optimize( -fschedule-insns2 )   #pragma GCC optimize( -fstrict-aliasing )   #pragma GCC optimize( -fstrict-overflow )   #pragma GCC optimize( -falign-functions )   #pragma GCC optimize( -fcse-skip-blocks )   #pragma GCC optimize( -fcse-follow-jumps )   #pragma GCC optimize( -fsched-interblock )   #pragma GCC optimize( -fpartial-inlining )   #pragma GCC optimize( no-stack-protector )   #pragma GCC optimize( -freorder-functions )   #pragma GCC optimize( -findirect-inlining )   #pragma GCC optimize( -fhoist-adjacent-loads )   #pragma GCC optimize( -frerun-cse-after-loop )   #pragma GCC optimize( inline-small-functions )   #pragma GCC optimize( -finline-small-functions )   #pragma GCC optimize( -ftree-switch-conversion )   #pragma GCC optimize( -foptimize-sibling-calls )   #pragma GCC optimize( -fexpensive-optimizations )   #pragma GCC optimize( -funsafe-loop-optimizations )   #pragma GCC optimize( inline-functions-called-once )   #pragma GCC optimize( -fdelete-null-pointer-checks )   #pragma GCC target(         sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native )   using namespace std;   struct node {     int next, to;   } w[2000010];   int n, m, cnt = 1, ans[1000005], h[1000005], top, ln, op, c[1000005],             dfn[1000005], timer, bj[1000005], v[1000005], id[2000005];   const int MAX_SIZE = 1 << 21;   char *l, *r, buf[MAX_SIZE];   inline int gc() {     if (l == r)       if (l == (r = (l = buf) + fread(buf, 1, MAX_SIZE, stdin))) return -1;     return *l++;   }   inline void read(int &x) {     register char c = gc();     for (; c < 48 || c > 57; c = gc())       ;     for (x = 0; c > 47 && c < 58; c = gc()) x = (x << 3) + (x << 1) + (c ^ 48);   }   inline void write(int x) {     if (x > 9) write(x / 10);     putchar(x % 10 +  0 );   }   void add(int x, int y, int z) {     cnt++;     w[cnt].to = y;     w[cnt].next = h[x];     id[cnt] = z;     h[x] = cnt;   }   inline void DFS1(int u, int co, int tag) {     register int i;     c[u] = co;     dfn[u] = ++timer;     for (i = h[u]; i; i = w[i].next) {       if (i == (tag ^ 1)) {         continue;       }       int e = w[i].to;       if (c[e] == 0) {         DFS1(e, 3 - co, i);       } else {         if (dfn[u] < dfn[e]) {           continue;         }         if (c[u] == c[e]) {           op++;           ln = i;           bj[u]++;           bj[e]--;         } else {           bj[u]--;           bj[e]++;         }       }     }   }   inline void DFS2(int u, int tag) {     register int i;     v[u] = 1;     for (i = h[u]; i; i = w[i].next) {       if (i == (tag ^ 1)) continue;       int e = w[i].to;       if (v[e] == 0) {         DFS2(e, i);         bj[u] += bj[e];       }     }     if (bj[u] == op) {       top++;       ans[top] = tag;     }   }   int main() {     register int i, x, y;     read(n);     read(m);     for (i = 1; i <= m; i++) {       read(x);       read(y);       if (x == y) {         op++;         add(0, 0, i);         ln = cnt;         continue;       }       add(x, y, i);       add(y, x, i);     }     for (i = 1; i <= n; i++) {       if (c[i] == 0) {         DFS1(i, 1, 0);       }     }     for (i = 1; i <= n; i++) {       if (v[i] == 0) {         DFS2(i, 0);       }     }     if (op == 0) {       write(m);       putchar(  n );       for (i = 1; i <= m; i++) {         write(i);         putchar(   );       }     } else {       if (op == 1) {         top++;         ans[top] = ln;       }       write(top);       putchar(  n );       sort(ans + 1, ans + 1 + top);       for (i = 1; i <= top; i++) {         write(id[ans[i]]);         putchar(   );       }     }   }