#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const long long MOD = 998244353;
inline long long add(long long x, long long y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
inline long long sub(long long x, long long y) {
  x -= y;
  if (x < 0) x += mod;
  return x;
}
inline long long mul(long long x, long long y) { return (x * 1ll * y) % mod; }
long long vis[300100];
long long col[300100];
long long po[300101];
vector<long long> adj[300010], ad[200100];
long long a, b;
bool bia(long long n, long long c) {
  vis[n] = 1;
  if (c == 0)
    a++;
  else
    b++;
  col[n] = c;
  for (auto it : adj[n]) {
    if (!vis[it]) {
      if (bia(it, c ^ 1) == false) return false;
    } else if (col[it] == col[n])
      return false;
  }
  return true;
}
signed main() {
  po[0] = 1;
  for (long long i = 1; i < 300010; i++) po[i] = mul(po[i - 1], 2);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    for (long long i = 0; i < n + 1; i++)
      adj[i].clear(), vis[i] = 0, col[i] = 0;
    long long x, y;
    for (long long i = 0; i < m; i++) {
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    long long f = 0;
    long long ans = 1;
    for (long long i = 1; i <= n; i++) {
      if (vis[i] == 0) {
        a = b = 0;
        bool res = bia(i, 0);
        if (res == false) f = 1;
        long long p = add(po[a], po[b]);
        ans = mul(ans, p);
      }
    }
    if (f)
      cout << 0;
    else
      cout << ans;
    cout << endl;
  }
}
