#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
long long modpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}
void solve() {
  long long n, m;
  std::cin >> n >> m;
  vector<vector<long long>> edges(n);
  for (int j = 0; j < m; j++) {
    long long a, b;
    std::cin >> a >> b;
    a--;
    b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  vector<int> done(n, 0);
  vector<pair<long long, long long>> ans;
  for (int i = 0; i < n; i++) {
    if (done[i] != 0) continue;
    pair<long long, long long> cnt = {0, 0};
    done[i] = 1;
    cnt.first++;
    queue<long long> q;
    q.push(i);
    while (q.size()) {
      auto now = q.front();
      q.pop();
      auto v = done[now];
      for (auto e : edges[now]) {
        if (done[e] == 0) {
          done[e] = 2 - (v == 2);
          if (done[e] == 2) {
            cnt.second++;
          } else {
            cnt.first++;
          }
          q.push(e);
        } else {
          if (done[e] != 2 - (v == 2)) {
            std::cout << 0 << std::endl;
            return;
          }
        }
      }
    }
    ans.push_back(cnt);
  }
  long long res = 1;
  for (auto e : ans) {
    res *= (modpow(2, e.first) + modpow(2, e.second)) % MOD;
    res %= MOD;
  }
  std::cout << res << std::endl;
}
int main() {
  long long t;
  std::cin >> t;
  for (int i = 0; i < t; i++) {
    solve();
  }
}
