#include <bits/stdc++.h>
using namespace std;
long long n, m, t, res, mod = 998244353, x, y, power[300300], w, q, now;
vector<vector<long long> > my(300005);
long long color[300300];
bool vis[300300];
long long bipartite(long long u) {
  x = 1, y = 0;
  queue<long long> q;
  color[u] = 1;
  q.push(u);
  while (!q.empty()) {
    long long temp = q.front();
    vis[temp] = 1;
    q.pop();
    for (long long i = 0; i < my[temp].size(); i++) {
      long long v = my[temp][i];
      if (color[v] == -1) {
        q.push(v);
        color[v] = 3 - color[temp];
        x += (color[v] == 1);
        y += (color[v] == 2);
      } else if (color[v] == color[temp])
        return 0;
    }
  }
  return (power[x] + power[y]) % mod;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  power[0] = 1;
  for (long long i = 1; i <= 3e5; i++) {
    power[i] = power[i - 1] * 2;
    power[i] %= mod;
  }
  cin >> t;
  while (t--) {
    cin >> n >> m;
    res = 1;
    for (long long i = 1; i <= n; i++) {
      my[i].clear();
      color[i] = -1;
      vis[i] = 0;
    }
    for (long long i = 0; i < m; i++) {
      cin >> q >> w;
      my[q].push_back(w);
      my[w].push_back(q);
    }
    bool ok = 1;
    for (long long i = 1; i <= n; i++)
      if (!vis[i]) {
        now = bipartite(i);
        if (!now) ok = 0;
        res *= now;
        res %= mod;
      }
    if (ok)
      cout << res % mod << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}
