#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const long long mod = 998244353;
vector<int> adj[N];
long long POW[N];
int n, m, VIS = 1;
long long tmp1 = 0, tmp2 = 0;
bool cyc = 0;
int vis[N];
bool color[N];
void init() {
  VIS++;
  for (int i = 0; i <= n; i++) {
    adj[i].clear();
    color[i] = 0;
  }
  tmp1 = tmp2 = 0;
  cyc = 0;
}
void dfs(int u) {
  vis[u] = VIS;
  if (color[u] == 1)
    tmp1++;
  else
    tmp2++;
  for (auto v : adj[u]) {
    if (vis[v] == VIS) {
      if (color[u] == color[v]) cyc = 1;
      continue;
    }
    color[v] = !color[u];
    dfs(v);
  }
}
long long pow_(long long a, long long b, long long mod) {
  long long ans = 1ll;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
int main() {
  int t;
  POW[0] = 1;
  for (int i = 1; i < N; i++) {
    POW[i] = (POW[i - 1] * 2ll) % mod;
    POW[i] %= mod;
  }
  scanf("%d", &t);
  for (int k = 0; k < t; k++) {
    if (k >= 1) init();
    scanf("%d %d", &n, &m);
    int u, v;
    for (int i = 0; i < m; i++) {
      scanf("%d %d", &u, &v);
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    long long ans = 1;
    for (int i = 1; i <= n; i++) {
      if (vis[i] == VIS) continue;
      dfs(i);
      ans *= (POW[tmp1] % mod + POW[tmp2] % mod) % mod;
      ans %= mod;
      tmp1 = 0;
      tmp2 = 0;
    }
    if (cyc) {
      printf("0\n");
      continue;
    }
    printf("%lld\n", ans);
  }
}
