#include <bits/stdc++.h>
using namespace std;
bool ok;
int head[300000 + 5], cnt;
int book[300000 + 5];
long long ans;
int n, m, p, s;
struct node {
  int v;
  int nxt;
} edge[600000 + 10];
long long poww(long long a, long long b) {
  long long ans = 1, base = a;
  while (b != 0) {
    if ((b & 1) != 0) ans = (ans * base) % 998244353;
    base = (base * base) % 998244353;
    b >>= 1;
  }
  return ans;
}
void add(int u, int v) {
  edge[cnt].v = v;
  edge[cnt].nxt = head[u];
  head[u] = cnt++;
}
void dfs(int now, int flag) {
  if (flag == 1)
    p++;
  else
    s++;
  book[now] = flag;
  int v;
  for (int i = head[now]; i != -1; i = edge[i].nxt) {
    v = edge[i].v;
    if (book[v] == -1) {
      dfs(v, (flag + 1) % 2);
    } else if (book[v] == flag) {
      ok = 0;
      return;
    }
  }
}
int main() {
  int t, u, v;
  scanf("%d", &t);
  while (t--) {
    cnt = 0;
    ok = 1;
    ans = 1;
    scanf("%d%d", &n, &m);
    for (int i = 0; i <= n; i++) {
      head[i] = -1;
      book[i] = -1;
    }
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &u, &v);
      add(u, v);
      add(v, u);
    }
    for (int st = 1; st <= n; st++) {
      if (book[st] != -1)
        continue;
      else {
        p = 0;
        s = 0;
        dfs(st, 1);
        ans = ans * (poww(2, p) + poww(2, s)) % 998244353;
      }
    }
    if (ok)
      printf("%I64d\n", ans);
    else
      printf("0\n");
  }
  return 0;
}
