#include <bits/stdc++.h>
using namespace std;
vector<int> g[300005];
int col[300005];
bool vis[300005];
bool oddLenCycle = false;
long long int pow2[300005];
int zero = 0, one = 0;
void dfs(int x, int c = 0) {
  vis[x] = true;
  col[x] = c;
  if (c)
    one++;
  else
    zero++;
  for (int u : g[x]) {
    if (vis[u]) {
      if (col[u] == col[x]) {
        oddLenCycle = true;
        return;
      }
      continue;
    }
    dfs(u, c ^ 1);
  }
}
int main() {
  pow2[0] = 1;
  for (int i = 1; i < 300005; i++) pow2[i] = (pow2[i - 1] * 2) % 998244353;
  int t;
  scanf("%d", &t);
  memset(col, -1, sizeof(col));
  while (t--) {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      g[u].push_back(v);
      g[v].push_back(u);
    }
    oddLenCycle = false;
    long long int ans = 1;
    for (int i = 1; i <= n; i++) {
      zero = one = 0;
      if (vis[i] == false) {
        dfs(i);
        long long int temp = (pow2[zero] + pow2[one]) % 998244353;
        ans = (ans % 998244353 * temp % 998244353) % 998244353;
      }
    }
    if (oddLenCycle)
      printf("0\n");
    else {
      printf("%lld\n", ans % 998244353);
    }
    for (int i = 1; i <= n; i++) {
      g[i].clear();
      vis[i] = false;
      col[i] = -1;
    }
  }
  return 0;
}
