2 0
 100000 0
 8 9
1 2
2 3
3 4
4 1
5 6
6 7
7 8
8 5
6 8
 2 1
1 2
 11 9
5 9
8 5
11 3
11 1
3 4
7 11
3 1
11 2
7 2
 7 9
7 3
7 4
1 2
2 3
3 1
3 4
4 5
5 6
6 4
 7 5
5 4
7 3
7 1
6 7
3 1
 7 8
1 2
2 3
3 4
4 1
3 5
5 6
6 7
7 3
 6 9
1 2
2 3
1 4
4 2
5 2
5 3
4 5
6 4
6 5
 7 9
1 2
2 4
4 3
3 1
2 3
4 5
5 6
6 7
7 4
 1 0
 6 7
1 2
2 3
3 1
3 4
4 5
5 6
6 4
 4 5
1 2
2 3
3 4
4 1
1 3
 100000 3
99998 99999
99999 100000
100000 99998

0

 0

 4
1 2 3 4 
 0

 6
3 4 6 7 8 9 
 9
1 2 3 4 5 6 7 8 9 
 3
2 3 5 
 8
1 2 3 4 5 6 7 8 
 0

 4
6 7 8 9 
 0

 6
1 2 3 5 6 7 
 0

 3
1 2 3 

class Graph:
    def __init__(self, n, edges):
        self.vertex = [[] for i in range(n)]
        for i in range(len(edges)):
            self.vertex[edges[i][0] - 1].append(edges[i][1] - 1)
            self.vertex[edges[i][1] - 1].append(edges[i][0] - 1)
        self.count = len(self.vertex)
        
    def __repr__(self):
        return str(self.vertex)

class ResultCase:
    def __init__(self, edges = []):
        self.edges = edges
        self.count = lambda : len(self.edges)

    def add(self, x: int):
        self.edges.append(x)

    def __repr__(self):
        sedges = ""
        if self.count() != 0:
            for i in enumerate(sorted(self.edges)):
                sedges += "{} ".format(i[1])
        return "{}\n{}".format(self.count(), sedges)


class TestCase:
    def __init__(self, n, m, edges = []):
        self.n = n
        self.m = m
        self.edges = dict([(tuple(edges[i]), i) for i in range(len(edges))])  
        self.G = None
    
    def done(self):
        self.G = Graph(self.n, list(self.edges.keys()))
    def __repr__(self):
        return "~~~ CASE ~~~\nn={}\nm={}\nedges={}\n~~~~~~~~~~~~".format(self.n, self.m, self.edges)

def read_input():
    line = input()
    spl = line.split()
    case = TestCase(int(spl[0]), int(spl[1]))
    for i in range(case.m):
        line = input()
        spl = line.split()
        case.edges[tuple([int(spl[0]), int(spl[1])])] = i
    case.done()
    return case

class DisjointSet:
    def __init__(self, elements: list):
        self.elements = elements
        self.P = [-1 for i in range(len(self.elements))]
    
    def SetOf(self, x: int):
        if self.P[x] < 0:
            return x
        return self.SetOf(self.P[x])
    
    def Merge(self, x: int, y: int):
        c_x = self.SetOf(x)
        c_y = self.SetOf(y)

        if c_x == c_y:
            return

        if abs(self.P[c_x]) < abs(self.P[c_y]):
            self.P[c_y] += self.P[c_x]
            self.P[c_x] = c_y
        else:
            self.P[c_x] += self.P[c_y]
            self.P[c_y] = c_x

class DFS:
    def __init__(self, g: Graph):
        self.dep = []
        self.color = []
        self.p = []
        #to store reverse edges
        self.be = []

        self.G = g

    def run(self):
        self.dep = [0 for i in range(self.G.count)]
        self.color = [0 for i in range(self.G.count)]
        self.p = [-1 for i in range(self.G.count)]

        for i in range(self.G.count):
            if self.color[i] == 0:
                self.dfs(i, -1, 0)

    def dfs(self, u: int, pi_u: int, deep: int):
        self.dep[u] = deep
        self.color[u] = 1
        self.p[u] = pi_u

        for i in range(len(self.G.vertex[u])):
            v = self.G.vertex[u][i]
            if v == pi_u:
                continue
            elif self.p[v] == -1:
                self.dfs(v, u, deep + 1)
            elif self.color[v] == 1:
                self.be.append([u,v])

        self.color[u] = 2
    
    def __repr__(self):
        return "dep = {}\ncolor = {}\np = {}\nbe = {}".format(self.dep, self.color, self.p, self.be)

def check_key(dictionary: dict, dkey: tuple):
    if dictionary.keys().__contains__(dkey):
        return dkey
    elif dictionary.keys().__contains__((dkey[1], dkey[0])):
        return (dkey[1], dkey[0])
    return None


    
if __name__ == "__main__":
    #case = TestCase(3, 2, [[0, 1], [1,2], [2,0]])
    #case.done()
    case = read_input()
    dfs_iter = DFS(case.G)
    dfs_iter.run()
    pp = dfs_iter.p.copy()
    index = [-1 for i in range(case.G.count)]
    dsu = DisjointSet(dfs_iter.be)

    for i in range(len(dfs_iter.be)):
        x = dfs_iter.be[i][0]
        path = []
        while dfs_iter.dep[x] > dfs_iter.dep[dfs_iter.be[i][1]]:
            path.append(x)
            if index[x] == -1:
                index[x] = i
            else:
                dsu.Merge(i, index[x])
            x = dfs_iter.p[x]
        for j in range(len(path)):
            dfs_iter.p[j] = dfs_iter.be[i][1]
    result = ResultCase()
    for i in range(len(dfs_iter.be)):
        if dsu.P[i] < 0 and abs(dsu.P[i]) == 1:

            t = check_key(case.edges, tuple([dfs_iter.be[i][0]+ 1, dfs_iter.be[i][1] + 1]))
            if t != None:
                result.add(1 + case.edges[t])
            else:
                raise Exception("This key isn't in dict")
            
            y = dfs_iter.be[i][0]
            while y != dfs_iter.be[i][1]:
                te = check_key(case.edges, tuple([y + 1,  pp[y] + 1]))
                if te != None:
                    result.add(1 + case.edges[te])
                else:
                    raise Exception("This key isn't in dict")
                y = pp[y]
    print(result)
