#include <bits/stdc++.h>
using namespace std;
const long long N = 4 * 100000;
vector<long long> adj[N];
long long color[N];
void rem(long long n) {
  for (long long i = 0; i <= n; i++) adj[i].clear();
}
bool dfs(long long num, long long src, long long* ans1, long long* ans2,
         long long col) {
  color[src] = col;
  if (num == 1)
    *ans1 = ((*ans1) * 2) % (long long)998244353;
  else
    *ans2 = ((*ans2) * 2) % (long long)998244353;
  long long sz = adj[src].size();
  bool check = true;
  for (long long i = 0; i < sz; i++) {
    if (color[adj[src][i]] == -1) {
      bool temp = dfs(1 - num, adj[src][i], ans1, ans2, 1 - col);
      if (temp == false) check = false;
    } else if (color[adj[src][i]] == color[src])
      check = false;
  }
  return check;
}
signed main() {
  long long t;
  scanf("%lld", &t);
  while (t--) {
    long long n, m;
    scanf("%lld%lld", &n, &m);
    rem(n);
    for (long long i = 1; i <= m; i++) {
      long long a, b;
      scanf("%lld%lld", &a, &b);
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    for (long long i = 0; i <= n; i++) color[i] = -1;
    long long ans = 1;
    for (long long i = 1; i <= n; i++) {
      if (color[i] == -1) {
        long long ans1 = 1, ans2 = 1;
        bool check = dfs(1, i, &ans1, &ans2, 1);
        if (check == false) {
          ans = 0;
          break;
        }
        ans = (ans * (ans1 + ans2)) % (long long)998244353;
      }
    }
    printf("%lld\n", ans);
  }
}
