#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
const double EPS = 1e-9;
int T, n, m;
vector<int> e[300015];
int vis[300015];
pair<int, int> bfs(int x) {
  queue<int> que;
  que.push(x);
  vis[x] = 1;
  int cnt1 = 0, cnt2 = 0;
  ;
  while (que.size()) {
    int x = que.front();
    que.pop();
    if (1 == vis[x])
      ++cnt1;
    else
      ++cnt2;
    for (int i = 0; i < e[x].size(); ++i) {
      int y = e[x][i];
      if (vis[y] == vis[x]) return pair<int, int>(-1, -1);
      if (vis[y]) continue;
      vis[y] = -vis[x];
      que.push(y);
    }
  }
  return pair<int, int>(cnt1, cnt2);
}
int pow2[300015];
int main() {
  pow2[0] = 1;
  for (int i = 1; i <= 300000; ++i) {
    pow2[i] = pow2[i - 1] * 2 % MOD;
  }
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) e[i].clear();
    for (int i = 1; i <= m; ++i) {
      int u, v;
      scanf("%d%d", &u, &v);
      e[u].push_back(v), e[v].push_back(u);
    }
    for (int i = 1; i <= n; ++i) vis[i] = 0;
    long long ans = 1;
    for (int i = 1; i <= n; ++i) {
      if (!vis[i]) {
        pair<int, int> res = bfs(i);
        if (-1 == res.first) ans = 0;
        ans = ans * (pow2[res.first] + pow2[res.second]) % MOD;
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
