#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 2;
const int M = 998244353;
const int tox[4] = {1, -1, 0, 0};
const long long inf = 1e18;
const int toy[4] = {0, 0, 1, -1};
int n, m;
long long cnt[2];
long long ans = 1;
vector<int> col;
vector<vector<int>> g;
bool ok1;
void bad() { ans = 0; }
long long binpow(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2) {
    long long to = binpow(a, b / 2);
    return ((to * to) % M * a) % M;
  } else {
    long long to = binpow(a, b / 2);
    return (to * to) % M;
  }
}
void dfs(int v) {
  cnt[col[v] - 1]++;
  for (auto &z : g[v]) {
    if (col[z] == col[v]) bad();
    bool ok = (col[z] == 0);
    if (col[v] == 1) {
      col[z] = 2;
    } else {
      col[z] = 1;
    }
    if (ok) {
      dfs(z);
    }
  }
}
void solve() {
  cin >> n >> m;
  g.assign(n, vector<int>());
  col.assign(n, 0);
  ans = 1;
  int v, u;
  for (int i = 0; i < m; i++) {
    cin >> v >> u;
    --v;
    --u;
    g[v].emplace_back(u);
    g[u].emplace_back(v);
  }
  ok1 = 1;
  for (int i = 0; i < n; i++) {
    if (!col[i]) {
      cnt[0] = 0;
      cnt[1] = 0;
      col[i] = 1;
      dfs(i);
      long long to = (binpow(2, cnt[0]) + binpow(2, cnt[1])) % M;
      ans = (ans * to) % M;
    }
  }
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
