#include <bits/stdc++.h>
using namespace std;
const int M = 998244353, N = 300002;
struct node {
  int to, ne;
} e[N << 1];
bool fl[N], vis[N], flag;
int h[N], i, x, y, T, pi, sum, s[2], tot, n, m;
queue<int> q;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int rd() {
  int x = 0, fl = 1;
  char ch = gc();
  for (; ch < 48 || ch > 57; ch = gc())
    if (ch == '-') fl = -1;
  for (; 48 <= ch && ch <= 57; ch = gc()) x = (x << 3) + (x << 1) + (ch ^ 48);
  return x * fl;
}
inline void wri(int a) {
  if (a < 0) a = -a, putchar('-');
  if (a >= 10) wri(a / 10);
  putchar(a % 10 | 48);
}
inline void wln(int a) {
  wri(a);
  puts("");
}
int pw(int x, int y) {
  int z = 1;
  for (; y; y >>= 1, x = 1ll * x * x % M)
    if (y & 1) z = 1ll * z * x % M;
  return z;
}
void add(int x, int y) {
  e[++tot] = (node){y, h[x]};
  h[x] = tot;
}
int bfs(int u) {
  while (!q.empty()) q.pop();
  q.push(u);
  vis[u] = 1;
  s[0] = s[1] = 0;
  while (!q.empty()) {
    u = q.front(), q.pop();
    s[fl[u]]++;
    for (int i = h[u], v; i; i = e[i].ne)
      if (!vis[v = e[i].to])
        vis[v] = 1, q.push(v), fl[v] = fl[u] ^ 1;
      else if (fl[v] == fl[u])
        return -1;
  }
  sum = (pw(2, s[0]) + pw(2, s[1])) % M;
  return 0;
}
int main() {
  for (T = rd(); T--;) {
    n = rd(), m = rd();
    tot = 0;
    memset(fl, 0, n + 1);
    memset(h, 0, (n + 1) << 2);
    memset(vis, 0, n + 1);
    for (i = 1; i <= m; i++) x = rd(), y = rd(), add(x, y), add(y, x);
    flag = 1;
    pi = 1;
    for (i = 1; i <= n && flag; i++)
      if (!vis[i]) {
        if (bfs(i) == -1)
          flag = 0;
        else
          pi = 1ll * pi * sum % M;
      }
    if (flag)
      printf("%d\n", (pi + M) % M);
    else
      puts("0");
  }
}
