#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 110;
const int INF = 0x3f3f3f3f;
int map[maxn][maxn], used[maxn][maxn], lowc[maxn],pre[maxn];
int n, m, vis[maxn], Max[maxn][maxn];
void init ()
{
for (int i=0; i<maxn; i++)
for (int j=0; j<maxn; j++)
if (i == j)
map[i][j] = 0;
else
map[i][j] = INF;
memset (used, 0, sizeof(used));
memset (lowc, 0, sizeof(lowc));
memset (pre, 0, sizeof(pre));
memset (vis, 0, sizeof(vis));
}
int prim (int s)
{
int ans = 0, mini, p;
for (int i=1; i<=n; i++)
{
lowc[i] = map[s][i];
pre[i] = s;
}
vis[s] = 1;
for (int i=1; i<n; i++)
{
mini = INF;
for (int j=1; j<=n; j++)
{
if (!vis[j] && mini>lowc[j])
{
mini = lowc[j];
p = j;
}
}
ans += mini;
vis[p] = 1;
used[p][pre[p]] = used[pre[p]][p] = 1;
for (int j=1; j<=n; j++)
{
if (vis[j] && p!=j)
Max[p][j] = Max[j][p] = max (Max[j][pre[p]], lowc[p]);
if (!vis[j] && map[j][p]<lowc[j])
{
lowc[j] = map[j][p];
pre[j] = p;
}
}
}
return ans;
}
int SMST (int ans)
{
int mini = INF;
for (int i=1; i<=n; i++)
for (int j=i+1; j<=n; j++)
if (!used[i][j] && map[i][j]!=INF)
mini = min (mini, ans - Max[i][j] + map[i][j]);
return mini;
}
int main ()
{
int t;
scanf ("%d", &t);
while (t --)
{
init ();
scanf ("%d %d", &n, &m);
while (m --)
{
int u, v, s;
scanf ("%d %d %d", &u, &v, &s);
map[u][v] = map[v][u] = s;
}
int num1 = prim(1);
int num2 = SMST(num1);
if (num1 != num2)
printf ("%d
", num1);
else
printf ("Not Unique!
");
}
return 0;
}