#include <bits/stdc++.h>
using namespace std;
const int N = 300300;
int n, m;
vector<int> adj[N];
long long int gp[N], cnt, pw[N], now;
bool dfs(int v, int cur = 0) {
  now++;
  gp[v] = cur;
  cnt += cur == 0;
  for (int u : adj[v]) {
    if (gp[u] != -1) {
      if (gp[u] == gp[v]) {
        return 1;
      }
      continue;
    }
    if (dfs(u, !cur)) {
      return 1;
    }
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
  scanf("%d", &tt);
  pw[0] = 1;
  const long long int mod = 998244353;
  for (int i = 1; i < N; i++) {
    pw[i] = pw[i - 1] * 2 % mod;
  }
  while (tt--) {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) {
      adj[i].clear();
      gp[i] = -1;
    }
    for (int i = 0; i < m; i++) {
      int a, b;
      scanf("%d %d", &a, &b);
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    bool can = 1;
    long long int ans = 1;
    for (int i = 1; i <= n; i++) {
      if (gp[i] == -1) {
        cnt = 0, now = 0;
        can &= !dfs(i);
        ans = ans * (pw[cnt] + pw[now - cnt]) % mod;
      }
    }
    if (!can) {
      ans = 0;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
