import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    int n, m;
    scan(n);
    scan(m);

    auto rank = new int[](n + 1);
    auto rank_rev = new int[](n + 1);
    auto lose = new int[](n + 1);
    auto fix = new int[][](n + 1, 0);

    foreach (i ; 0 .. m) {
        int a, b;
        scan(a, b); // a ??? b ????????£???
        fix[a] ~= b;
        fix[b] ~= a;
        lose[b]++;
    }

    bool prob = false;

    foreach (i ; 0 .. n) {
        int x = -1;

        foreach (j ; 1 .. n + 1) {
            if (lose[j] == i) {
                if (x != -1) {
                    prob = true;
                }
                x = j;
            }
        }

        rank[x] = i + 1;
        rank_rev[i + 1] = x;

        bool[] update = new bool[](n + 1);
        update[] = true;

        foreach (y ; fix[x]) {
            update[y] = false;
        }

        foreach (y ; 1 .. n + 1) {
            if (update[y] && !rank[y]) {
                lose[y]++;
            }
        }
    }

    writefln("%(%s\n%)", rank_rev[1 .. $]);
    writeln(prob ? 1 : 0);

}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}