// #define MODULAR_ARITHMETIC
// #define INDEXED_SET
#ifndef LOCAL_DEBUG
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#endif

#include <stdarg.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <chrono>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <set>
#define pb push_back
#define mp make_pair
#define f(i, a, b) for (int i = a; i < b; i++)
#define revf(i, b, a) for (int i = b; i >= a; i--)
#define srt(v) sort(v.begin(), v.end())
#define rev_srt(v) sort(v.rbegin(), v.rend())
using namespace std;

#ifdef MODULAR_ARITHMETIC
template <typename T>
T add(T a, T b, T c)
{
    T res = a + b;
    return (res >= c ? res - c : res);
}
template <typename T>
T mod_neg(T a, T b, T c)
{
    T res;
    if (abs(a - b) < c)
        res = a - b;
    else
        res = (a - b) % c;
    return (res < 0 ? res + c : res);
}
template <typename T>
T mul(T a, T b, T c)
{
    ll res = (ll)a * b;
    return (res >= c ? res % c : res);
}
ll mulmod(ll a, ll b, ll m)
{
    ll q = (ll)(((LD)a * (LD)b) / (LD)m);
    ll r = a * b - q * m;
    if (r > m)
        r %= m;
    if (r < 0)
        r += m;
    return r;
}
template <typename T>
T expo(T e, T n)
{
    T x = 1, p = e;
    while (n)
    {
        if (n & 1)
            x = x * p;
        p = p * p;
        n >>= 1;
    }
    return x;
}
template <typename T>
T power(T e, T n, T m)
{
    T x = 1, p = e;
    while (n)
    {
        if (n & 1)
            x = mul(x, p, m);
        p = mul(p, p, m);
        n >>= 1;
    }
    return x;
}
template <typename T>
T extended_euclid(T a, T b, T &x, T &y)
{
    T xx = 0, yy = 1;
    y = 0;
    x = 1;
    while (b)
    {
        T q = a / b, t = b;
        b = a % b;
        a = t;
        t = xx;
        xx = x - q * xx;
        x = t;
        t = yy;
        yy = y - q * yy;
        y = t;
    }
    return a;
}
template <typename T>
T mod_inverse(T a, T n)
{
    T x, y, z = 0;
    T d = extended_euclid(a, n, x, y);
    return (d > 1 ? -1 : mod_neg(x, z, n));
}
#endif

#ifdef INDEXED_SET
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#endif

#define endl '\n'
#define precision(x) cout << fixed << setprecision(x);
#define fio                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

ll mod = 1e9 + 7;
const int max_n = 5.0 * 1e5 + 5;

vvi adjacent;
vi visited, path_pos;
int mn = 1e6;
void dfs(int vertex, int pos)
{
    if (visited[vertex])
    {
        if (path_pos[vertex])
        {
            mn = min(mn, pos - path_pos[vertex]);
        }
        return;
    }
    visited[vertex] = 1;
    path_pos[vertex] = pos;
    for (auto child : adjacent[vertex])
    {
        dfs(child, pos + 1);
    }
    path_pos[vertex] = 0;
    return;
}
int done = 0;
vi cycle;
void dfs2(int vertex, int pos)
{
    if (visited[vertex])
    {
        if (path_pos[vertex])
        {
            if (mn == pos - path_pos[vertex] && !done)
            {
                cycle.resize(pos - path_pos[vertex]);
                int index = 0;
                for (auto ver : path_pos)
                {
                    if (ver >= path_pos[vertex])
                    {
                        cycle[ver - path_pos[vertex]] = index;
                    }
                    index++;
                }
                done = 1;
            }
        }
        return;
    }
    visited[vertex] = 1;
    path_pos[vertex] = pos;
    for (auto child : adjacent[vertex])
    {
        dfs2(child, pos + 1);
    }
    path_pos[vertex] = 0;
    return;
}
int total = 0;
bool matrix[1005][1005] = {};
void minimize(vi cycle)
{
    if (done)
        return;
    int n = cycle.size();
    int flag = 0;
    vi nw;
    for (int i = 0; i < n && !flag && !done; i++)
    {
        int u = cycle[i];
        // cout << cycle[i] << endl;
        for (int j = 2; j < n && !done; j++)
        {
            int v = cycle[(i + j) % n];
            // cout << cycle[(i + j) % n] << " ";
            if (matrix[u][v])
            {
                int ind = (i + j) % n;
                while (cycle[ind % n] != u)
                {
                    nw.pb(cycle[ind % n]);
                    ind++;
                }
                nw.pb(u);
                flag = 1;
                break;
            }
        }
        // cout << endl;
    }
    if (flag)
    {
        minimize(nw);
    }
    else
    {
        cout << cycle.size() << endl;
        for (auto child : cycle)
            cout << child + 1 << endl;
        done = 1;
    }
}

void solvetestcase()
{
    int n, m, u, v;
    cin >> n >> m;
    total = n;
    adjacent.resize(n);
    path_pos.resize(n, 0);
    visited.resize(n, 0);
    f(i, 0, m)
    {
        cin >> u >> v;
        adjacent[u - 1].pb(v - 1);
        matrix[u - 1][v - 1] = 1;
    }
    f(i, 0, n)
    {
        if (!visited[i])
        {
            dfs(i, 1);
        }
    }
    if (mn == 1e6)
        cout << -1 << endl;
    else
    {
        f(i, 0, n)
        {
            visited[i] = 0;
            path_pos[i] = 0;
        }
        f(i, 0, n)
        {
            if (!visited[i] && !done)
            {
                dfs2(i, 1);
            }
        }
        done = 0;
        minimize(cycle);
    }
    return;
}

int main()
{
    fio;
    int t = 1;

    // UNCOMMENT FOR TESTCASES	\
	cin >> t;

    f(T, 1, t + 1)
    {
        // UNCOMMENT FOR CODEJAM,HACKERCUP	\
		cout << "Case #" << T << ": ";
        solvetestcase();
    }
};

/*
    AUTHOR:     KUNAL TAWATIA
    EDUCATION:  INDIAN INSTITUTE OF TECHNOLOGY, JODHPUR
*/

Measured memory_bytes: 1408