#include <bits/stdc++.h>
using namespace std;
long long vis[300005];
long long evn[300005];
std::vector<vector<long long>> edg;
long long countt;
long long total;
long long flag;
long long gogetpow(long long n) {
  long long mod = 998244353;
  long long result = 1;
  for (int i = 1; i <= n; i++) {
    result = (result * 2) % mod;
  }
  return result;
}
void dfs(long long p, long long status) {
  if (flag) return;
  vis[p] = 1;
  evn[p] = status;
  total++;
  if (status == 1) {
    countt++;
  }
  for (int i = 0; i < edg[p].size(); i++) {
    if (vis[edg[p][i]] == -1) {
      dfs(edg[p][i], status ^ 1);
    } else {
      if (evn[edg[p][i]] != (status ^ 1)) {
        countt = 0;
        flag = 1;
        return;
      }
    }
  }
}
void solve() {
  long long n, m, x, y;
  cin >> n >> m;
  edg.resize(0);
  edg.resize(n + 1);
  vector<pair<long long, long long>> edges;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    edges.push_back({x, y});
    edg[x].push_back(y);
    edg[y].push_back(x);
  }
  for (int i = 0; i <= n; i++) {
    evn[i] = -1;
    vis[i] = -1;
  }
  long long ans = 1;
  long long mod = 998244353;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == -1) {
      total = 0;
      countt = 0;
      flag = 0;
      dfs(i, 1);
      if (flag) {
        ans = 0;
      }
      ans = (ans * ((gogetpow(countt) + gogetpow(total - countt)) % mod)) % mod;
    }
  }
  ans = (ans) % mod;
  cout << ans << endl;
  return;
}
int main() {
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
