#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 999;
const long long mod = 998244353;
struct edge {
  int to, nxt;
} e[maxn << 1];
int head[maxn], cnt;
int n, m;
long long bin[maxn];
long long num[2];
int col[maxn];
bool bad;
void dfs(int u, int c) {
  col[u] = c;
  ++num[c];
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (col[v] == -1) dfs(v, 1 - c);
    if (col[v] ^ col[u] == 0) bad = true;
  }
}
void init() {
  cnt = 0;
  bad = 0;
  memset(head, 0, sizeof(head[0]) * (n + 1));
  memset(col, -1, sizeof(col[0]) * (n + 1));
}
void add(int u, int v) {
  e[++cnt].to = v;
  e[cnt].nxt = head[u];
  head[u] = cnt;
}
int main() {
  bin[0] = 1;
  for (int i = 1; i < maxn; i++) {
    bin[i] = (bin[i - 1] * 2) % mod;
  }
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &m);
    init();
    for (int i = 0; i < m; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      add(u, v);
      add(v, u);
    }
    long long res = 1;
    for (int i = 1; i <= n; i++) {
      if (col[i] != -1) continue;
      bad == false;
      num[0] = num[1] = 0;
      dfs(i, 0);
      if (bad) {
        puts("0");
        break;
      }
      long long tmp = (bin[num[0]] + bin[num[1]]) % mod;
      res = (res * 1ll * tmp) % mod;
    }
    if (!bad) printf("%lld\n", res);
  }
  return 0;
}
