#include <bits/stdc++.h>
// #include "stdafx.h"
// #pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 998244353;
const int N = 3e5, M = N;
//=======================
vi g[N];
int a[N], col[N];
int n, m, valid;
void color(int u, int p, int c)
{
col[u] = c;
int nc = 3-c;
for(int v: g[u])
{
if(col[v]){
if(col[v] != nc) valid = false;
}
else color(v, u, 3-c);
}
}
void solve()
{
int i, x, y;
cin >> n >> m;
fo(i, n) g[i].clear(), col[i] = 0;
valid = true;
while(m--)
{
cin >> x >> y; x--, y--;
g[x].pb(y);
g[y].pb(x);
}
//This won't get AC in the case
//where the graph will be disconnected
//but the overall idea is this...
color(0, -1, 1);
if(!valid) cout << 0 << endl;
else {
ll ans = 0;
int cnt = 0;
fo(i, n) cnt += col[i] == 1;
ans = (mpow(2, cnt) + mpow(2, n-cnt)) % mod;
cout << ans << endl;
}
}
int main()
{
int t;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int i,n,k,j;
cin >> t;
while(t--) solve();
return 0;
}
int mpow(int base, int exp) {
base %= mod;
int result = 1;
while (exp > 0) {
if (exp & 1) result = ((ll)result * base) % mod;
base = ((ll)base * base) % mod;
exp >>= 1;
}
return result;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Ci8vICNpbmNsdWRlICJzdGRhZnguaCIKLy8gI3ByYWdtYSB3YXJuaW5nKGRpc2FibGUgOiA0OTk2KSAvL19DUlRfU0VDVVJFX05PX1dBUk5JTkdTCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgZ2MgZ2V0Y2hhcl91bmxvY2tlZAojZGVmaW5lIGZvKGksbikgZm9yKGk9MDtpPG47aSsrKQojZGVmaW5lIEZvKGksayxuKSBmb3IoaT1rO2s8bj9pPG46aT5uO2s8bj9pKz0xOmktPTEpCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgc2koeCkJc2NhbmYoIiVkIiwmeCkKI2RlZmluZSBzbCh4KQlzY2FuZigiJWxsZCIsJngpCiNkZWZpbmUgc3MocykJc2NhbmYoIiVzIixzKQojZGVmaW5lIHBpKHgpCXByaW50ZigiJWRcbiIseCkKI2RlZmluZSBwbCh4KQlwcmludGYoIiVsbGRcbiIseCkKI2RlZmluZSBwcyhzKQlwcmludGYoIiVzXG4iLHMpCiNkZWZpbmUgZGViKHgpIGNvdXQgPDwgI3ggPDwgIj0iIDw8IHggPDwgZW5kbAojZGVmaW5lIGRlYjIoeCwgeSkgY291dCA8PCAjeCA8PCAiPSIgPDwgeCA8PCAiLCIgPDwgI3kgPDwgIj0iIDw8IHkgPDwgZW5kbAojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIG1wIG1ha2VfcGFpcgojZGVmaW5lIEYgZmlyc3QKI2RlZmluZSBTIHNlY29uZAojZGVmaW5lIGFsbCh4KSB4LmJlZ2luKCksI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