#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
const long long mod = 998244353;
long long fpm(long long a, long long p) {
  long long r = 1, base = a;
  while (p) {
    if (p & 1) r = r * base % mod;
    base = base * base % mod;
    p /= 2;
  }
  return r;
}
long long vis[maxn], n, m, t;
vector<int> adj[maxn];
long long cnt1, cnt2;
bool flg;
long long ch(int co) {
  if (co == 1) return 2;
  return 1;
}
void dfs(int u, int co) {
  vis[u] = co;
  if (co == 1)
    cnt1++;
  else
    cnt2++;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (vis[v] != 0) {
      if (vis[v] != ch(co)) flg = 0;
      if (vis[v] != ch(co)) flg = 0;
      continue;
    }
    dfs(v, ch(co));
  }
}
long long work() {
  flg = 1;
  long long ans = 1;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      cnt1 = cnt2 = 0ll;
      dfs(i, 1);
      if (flg == 0) return 0;
      ans = (ans * (fpm(2, cnt1) + fpm(2, cnt2))) % mod;
    }
  }
  return ans;
}
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
      adj[i].clear();
      vis[i] = 0;
    }
    int u, v;
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &u, &v);
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    cout << work() << endl;
  }
}
