#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
vector<int> g[N];
int vis[N], cnt, e, o;
bool bfs(int node) {
  queue<int> q;
  q.push(node);
  vis[node] = 0;
  while (q.size()) {
    int node = q.front();
    cnt++;
    if (vis[node] == 0)
      e++;
    else
      o++;
    q.pop();
    for (auto u : g[node]) {
      if (vis[u] == -1) {
        vis[u] = vis[node] ^ 1;
        q.push(u);
      } else if (vis[u] == vis[node])
        return 1;
    }
  }
  return 0;
}
const int mod = 998244353;
long long fast_power(long long a, int b) {
  if (!b) return 1;
  long long t = fast_power(a, b >> 1);
  t = (t * t) % mod;
  if (b & 1) t *= a;
  return t % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
      g[i].clear();
      vis[i] = -1;
    }
    for (int i = 0, u, v; i < m; i++) {
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    bool flag = 0;
    long long ans = 1;
    for (int i = 1; i <= n; i++) {
      if (vis[i] == -1) {
        cnt = 0, e = 0, o = 0;
        flag |= bfs(i);
        long long temp = fast_power(2, e);
        temp += fast_power(2, o);
        temp %= mod;
        ans *= temp;
        ans %= mod;
      }
    }
    if (flag) {
      cout << 0 << '\n';
    } else {
      cout << ans << '\n';
    }
    for (int i = 1; i <= n; i++) {
      g[i].clear();
      vis[i] = -1;
    }
  }
  return 0;
}
