#include <bits/stdc++.h>
using namespace std;
const int nax = 3e5 + 111;
const int MOD = 998244353;
vector<vector<int>> G;
int color[nax];
pair<bool, pair<int, int>> dfs(int x, int parent) {
  color[x] = 3 - parent;
  bool isTwoColorable = true;
  int sizeOfComponent = 1;
  int cntOf2 = color[x] == 2;
  for (int v : G[x]) {
    if (!color[v]) {
      auto ret = dfs(v, color[x]);
      isTwoColorable = isTwoColorable && ret.first;
      sizeOfComponent += ret.second.first;
      cntOf2 += ret.second.second;
    } else {
      isTwoColorable = isTwoColorable && (color[v] == 3 - color[x]);
    }
  }
  return {isTwoColorable, {sizeOfComponent, cntOf2}};
}
int power(int base, int expo) {
  int ret = 1, to = base;
  while (expo) {
    if (expo % 2) {
      ret = ret * 1LL * to % MOD;
    }
    to = to * 1LL * to % MOD;
    expo /= 2;
  }
  return ret;
}
int calc(int N) { return (power(2, N / 2) + power(2, N - N / 2)) % MOD; }
int main() {
  int T, i;
  scanf("%d", &T);
  for (; T; --T) {
    G.clear();
    int N, M, x, y;
    scanf("%d%d", &N, &M);
    memset(color, 0, sizeof(int) * (N + 1));
    G.resize(N + 1);
    for (int i = 0; i < M; ++i) {
      scanf("%d%d", &x, &y);
      G[x].push_back(y);
      G[y].push_back(x);
    }
    bool ans = true;
    int out = 1;
    for (int i = 1; i <= N; ++i) {
      if (!color[i]) {
        auto x = dfs(i, 1);
        ans = ans && x.first;
        out = out * 1LL *
              ((power(2, x.second.second) +
                power(2, x.second.first - x.second.second)) %
               MOD) %
              MOD;
      }
    }
    if (!ans) {
      printf("%d\n", 0);
      continue;
    }
    printf("%d\n", out);
  }
  return 0;
}
