def find(i, m):
    if m[i] < 0:
        return i
    return find(m[i], m)


def count(i, m):
    if m[i] < 0:
        return abs(m[i])
    return count(m[i], m)


def main():
    n, m, *ab = map(int, open(0).read().split())
    ab = ab[::-1]
    tmp = n * (n - 1) // 2
    utl = []
    par = [-1] * (n + 1)

    for u, v in zip(ab[::2], ab[1::2]):
        if find(u, par) == find(v, par):
            utl.append(tmp)
        else:
            i, j = find(u, par), find(v, par)
            utl.append(tmp)
            tmp -= par[i] * par[j]
            if par[i] > par[j]:
                i, j = j, i
            par[i] += par[j]
            par[j] = i

    ans = '\n'.join(map(str, utl[::-1]))
    print(ans)


if __name__ == '__main__':
    main() def find(i, m):
    if m[i] < 0:
        return i
    return find(m[i], m) find if m[i] < 0:
        return i
     m[i] < 0 m[i] m i 0 return i i return find(m[i], m) find(m[i], m) find m[i] m i m i i m m def count(i, m):
    if m[i] < 0:
        return abs(m[i])
    return count(m[i], m) count if m[i] < 0:
        return abs(m[i])
     m[i] < 0 m[i] m i 0 return abs(m[i]) abs(m[i]) abs m[i] m i return count(m[i], m) count(m[i], m) count m[i] m i m i i m m def main():
    n, m, *ab = map(int, open(0).read().split())
    ab = ab[::-1]
    tmp = n * (n - 1) // 2
    utl = []
    par = [-1] * (n + 1)

    for u, v in zip(ab[::2], ab[1::2]):
        if find(u, par) == find(v, par):
            utl.append(tmp)
        else:
            i, j = find(u, par), find(v, par)
            utl.append(tmp)
            tmp -= par[i] * par[j]
            if par[i] > par[j]:
                i, j = j, i
            par[i] += par[j]
            par[j] = i

    ans = '\n'.join(map(str, utl[::-1]))
    print(ans) main n, m, *ab = map(int, open(0).read().split()) n map(int, open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split m *ab ab ab = ab[::-1] ab ab[::-1] ab ::-1 -1 tmp = n * (n - 1) // 2 tmp n * (n - 1) // 2 n * (n - 1) n n - 1 n 1 2 utl = [] utl [] par = [-1] * (n + 1) par [-1] * (n + 1) [-1] -1 n + 1 n 1 for u, v in zip(ab[::2], ab[1::2]):
        if find(u, par) == find(v, par):
            utl.append(tmp)
        else:
            i, j = find(u, par), find(v, par)
            utl.append(tmp)
            tmp -= par[i] * par[j]
            if par[i] > par[j]:
                i, j = j, i
            par[i] += par[j]
            par[j] = i

     u v zip(ab[::2], ab[1::2]) zip ab[::2] ab ::2 2 ab[1::2] ab 1::2 1 2 if find(u, par) == find(v, par):
            utl.append(tmp)
        else:
            i, j = find(u, par), find(v, par)
            utl.append(tmp)
            tmp -= par[i] * par[j]
            if par[i] > par[j]:
                i, j = j, i
            par[i] += par[j]
            par[j] = i

     find(u, par) == find(v, par) find(u, par) find u par find(v, par) find v par utl.append(tmp) utl.append utl append tmp i, j = find(u, par), find(v, par) i find(u, par) find u par j find(v, par) find v par utl.append(tmp) utl.append utl append tmp tmp -= par[i] * par[j] tmp par[i] * par[j] par[i] par i par[j] par j if par[i] > par[j]:
                i, j = j, i
             par[i] > par[j] par[i] par i par[j] par j i, j = j, i i j j i par[i] += par[j] par[i] par i par[j] par j par[j] = i par[j] par j i ans = '\n'.join(map(str, utl[::-1])) ans '\n'.join(map(str, utl[::-1])) '\n'.join '\n' join map(str, utl[::-1]) map str utl[::-1] utl ::-1 -1 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def count(i, m):
    if m[i] < 0:
        return abs(m[i])
    return count(m[i], m) def count(i, m):
    if m[i] < 0:
        return abs(m[i])
    return count(m[i], m) count def main():
    n, m, *ab = map(int, open(0).read().split())
    ab = ab[::-1]
    tmp = n * (n - 1) // 2
    utl = []
    par = [-1] * (n + 1)

    for u, v in zip(ab[::2], ab[1::2]):
        if find(u, par) == find(v, par):
            utl.append(tmp)
        else:
            i, j = find(u, par), find(v, par)
            utl.append(tmp)
            tmp -= par[i] * par[j]
            if par[i] > par[j]:
                i, j = j, i
            par[i] += par[j]
            par[j] = i

    ans = '\n'.join(map(str, utl[::-1]))
    print(ans) def main():
    n, m, *ab = map(int, open(0).read().split())
    ab = ab[::-1]
    tmp = n * (n - 1) // 2
    utl = []
    par = [-1] * (n + 1)

    for u, v in zip(ab[::2], ab[1::2]):
        if find(u, par) == find(v, par):
            utl.append(tmp)
        else:
            i, j = find(u, par), find(v, par)
            utl.append(tmp)
            tmp -= par[i] * par[j]
            if par[i] > par[j]:
                i, j = j, i
            par[i] += par[j]
            par[j] = i

    ans = '\n'.join(map(str, utl[::-1]))
    print(ans) main def find(i, m):
    if m[i] < 0:
        return i
    return find(m[i], m) def find(i, m):
    if m[i] < 0:
        return i
    return find(m[i], m) find
def find(i, m):
    if m[i] < 0:
        return i
    return find(m[i], m)


def count(i, m):
    if m[i] < 0:
        return abs(m[i])
    return count(m[i], m)


def main():
    n, m, *ab = map(int, open(0).read().split())
    ab = ab[::-1]
    tmp = n * (n - 1) // 2
    utl = []
    par = [-1] * (n + 1)

    for u, v in zip(ab[::2], ab[1::2]):
        if find(u, par) == find(v, par):
            utl.append(tmp)
        else:
            i, j = find(u, par), find(v, par)
            utl.append(tmp)
            tmp -= par[i] * par[j]
            if par[i] > par[j]:
                i, j = j, i
            par[i] += par[j]
            par[j] = i

    ans = '\n'.join(map(str, utl[::-1]))
    print(ans)


if __name__ == '__main__':
    main()
