#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int N = 3 * 1e5 + 10;
int n, m, cnt1, cnt2;
vector<int> G[N];
int color[N];
long long ans, fact[N];
bool fp;
void dfs(int u) {
  if (color[u] == 1)
    cnt1++;
  else
    cnt2++;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (color[u] == color[v]) {
      fp = false;
      return;
    }
    if (color[v]) continue;
    if (color[u] == 1)
      color[v] = 2;
    else if (color[u] == 2)
      color[v] = 1;
    dfs(v);
  }
}
int main() {
  fact[0] = 1;
  for (int i = 1; i < N; i++) fact[i] = fact[i - 1] * 2 % mod;
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &m);
    for (int i = 0; i <= n; i++) G[i].clear(), color[i] = 0;
    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);
    }
    fp = true;
    ans = 1;
    for (int i = 1; i <= n; i++)
      if (!color[i]) {
        cnt1 = cnt2 = 0;
        color[i] = 1;
        dfs(i);
        if (!fp) {
          ans = 0;
          break;
        }
        ans *= (long long)(fact[cnt1] + fact[cnt2]);
        ans %= mod;
      }
    printf("%lld\n", ans % mod);
  }
}
