#ifndef __APPLE__
#include <bits/stdc++.h>
#else
#include <iostream>
#include <vector>
#include <set>
#include "map"
#include "iomanip"
#include "cassert"
#include "numbers"
#include "random"
#endif
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
typedef long double ld;

vector<vector<int>> g;
vector<set<int>> gdown;
vector<set<pair<int, int>>> gup;
vector<int> dep;
vector<int> seen;
void dfsorig(int v) {
    seen[v] = 1;
    for (auto i : g[v]) {
        if (seen[i])
            gup[v].insert({dep[i], i});
    }
    if (!gup[v].empty()) {
        if (gup[v].rbegin()->first == (dep[v] - 1))
            gup[v].erase(--gup[v].end());
    }
    for (auto i : g[v]) {
        if (!seen[i]) {
            dep[i] = dep[v] + 1;
            dfsorig(i);
            gdown[v].insert(i);
        }
    }
}
struct dsu {
    vector<int> p;
    void init(int n) {
        p.assign(n, {});
        iota(all(p), 0ll);
    }
    int getv(int v) {
        if (p[v] == v)
            return v;
        return p[v] = getv(p[v]);
    }
    void mrg(int a, int b) {
        a = getv(a);
        b = getv(b);
        p[a] = b;
    }
};
dsu usd;
int slv(int v) {
    vector<int> deti;
    while (!gdown[v].empty()) {
        int iq = *gdown[v].begin();
        gdown[v].erase(gdown[v].begin());
        int c = slv(iq);
        if (c != -1)
            deti.push_back(c);
    }
    if (deti.size() % 2 == 1) {
        for (auto i : deti)
            usd.mrg(v, i);
        return -1;
    }
    if (deti.empty())
        return v;
    for (int i = 0; i < deti.size(); ++i) {
        if (gup[deti[i]].size())
            swap(deti[i], deti.back());
    }
    if (gup[deti.back()].empty()) {
        for (auto i : deti)
            usd.mrg(v, i);
        return v;
    } else {
        gdown[gup[deti.back()].rbegin()->second].insert(deti.back());
        gup[deti.back()].erase(--gup[deti.back()].end());
        deti.pop_back();
        for (auto i : deti)
            usd.mrg(v, i);
        return -1;
    }
}
void solve() {
    int n, m;
    cin >> n >> m;
    g.assign(n, {});
    gup.assign(n, {});
    gdown.assign(n, {});
    dep.assign(n, {});
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    if (n % 2) {
        cout << "-1\n";
        return;
    }
    seen.assign(n, {});
    dfsorig(0);
    usd.init(n);
    slv(0);
    for (int i = 0; i < n; ++i) {
        cout << usd.getv(i) + 1 << ' ';
    }
    cout << '\n';
}
signed main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    /*
    for (int i = 1; i < 200000; ++i) {
        int k = i * 2;
        k = (k * 2 + 2) / 3;
        if (k*2 > 3*i)
            cout << i << '\n';
    }exit(0);*/
    int t = 1;
    cin >> t;
    while (t--)
        solve();
}
/*
1
10 4
1 1 1 1 1 1 1 1 1 1
1 7
7 10
1 10
3 4
 */