#include <fstream>
#include <vector>
using namespace std;
ifstream fin ("ciclueuler.in");
ofstream fout ("ciclueuler.out");
pair <int, int> much[500001];
vector <int> v[100001];
bool ok[100001], okmuch[500001];
int s[500001], rasp[500001];
void dfsconex (int r)
{
ok[r] = 1;
int i;
for (i = 0; i<v[r].size(); i++)
if (ok[much[v[r][i]].first ^ much[v[r][i]].second ^ r] == 0)
dfsconex (much[v[r][i]].first ^ much[v[r][i]].second ^ r);
}
int main()
{
int n, m, i, x, y;
fin >> n >> m;
for (i = 1; i<=m; i++)
{
fin >> x >> y;
much[i] = {x, y};
v[x].push_back(i);
v[y].push_back(i);
}
dfsconex(1);
for (i = 1; i<=n; i++)
if (ok[i] == 0 || (v[i].size()&1))
{
fout << -1;
return 0;
}
s[0] = s[1] = 1;
while (s[0] > 0)
{
x = s[s[0]];
if (v[x].empty() == 0)
{
y = v[x].back();
v[x].pop_back();
if (okmuch[y] == 0)
{
okmuch[y] = 1;
s[++s[0]] = x ^ much[y].first ^ much[y].second;
}
}
else
{
rasp[++rasp[0]] = x;
s[0]--;
}
}
for (i = 1; i<=m; i++)
fout << rasp[i] << ' ';
return 0;
}