#include <bits/stdc++.h>
using namespace std;
long long pw(long long a, long long n) {
  if (n == 0) return 1;
  long long pt = pw(a, n / 2);
  pt *= pt * 1LL;
  pt %= 998244353;
  if (n & 1) pt *= a * 1LL;
  pt %= 998244353;
  return pt;
}
long long one, two;
bool dfs(vector<long long> graph[], long long node, long long *visited,
         long long parent, long long color) {
  visited[node] = color;
  color == 1 ? one++ : two++;
  for (auto nbr : graph[node]) {
    if (visited[nbr] == 0) {
      long long subprob = dfs(graph, nbr, visited, node, 3 - color);
      if (subprob == false) return false;
    } else if (nbr != parent && color == visited[nbr]) {
      return false;
    }
  }
  return true;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<long long> graph[n + 1];
  while (m--) {
    long long x, y;
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  long long visited[n + 1];
  for (long long i = 0; i <= n; i++) visited[i] = 0;
  long long ans = 1;
  for (long long i = 1; i <= n; i++) {
    if (visited[i] == 0) {
      one = 0;
      two = 0;
      bool can = dfs(graph, i, visited, -1, 1);
      if (!can) {
        cout << "0\n";
        return;
      }
      ans = (ans * (pw(2, one) % 998244353 + pw(2, two) % 998244353) %
             998244353) %
            998244353;
    }
  }
  cout << ans % 998244353 << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
